针对邮乐的修改
This commit is contained in:
parent
93d95254b7
commit
a7664d5ed2
|
@ -19,7 +19,7 @@ import (
|
|||
"trasfer_middleware/until"
|
||||
)
|
||||
|
||||
var configFile = flag.String("f", until.GetConfig(), "the config file")
|
||||
var configFile = flag.String("f", fmt.Sprintf("%s%s", "../../config/", until.GetConfig()), "the config file")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
. $(pwd)/sh/config.sh
|
||||
Environment="produce"
|
||||
ADDRESS="${PRODUCE_ADDRESS}"
|
||||
echo "produce"> $(pwd)/sh/env
|
||||
echo "produce"> $(pwd)/env
|
||||
|
||||
. $(pwd)/sh/build.sh
|
||||
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
. $(pwd)/sh/config.sh
|
||||
Environment="test"
|
||||
ADDRESS="${TEST_ADDRESS}"
|
||||
echo "test"> $(pwd)/sh/env
|
||||
echo "test"> $(pwd)/env
|
||||
sh $(pwd)/sh/build.sh
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
. $(pwd)/sh/config.sh
|
||||
|
||||
ENV=$(cat "$(pwd)/sh/env")
|
||||
ENV=$(cat "$(pwd)/env")
|
||||
# 使用if-elif-else结构判断环境
|
||||
if [ "$ENV"=="produce" ]; then
|
||||
ADDRESS="${PRODUCE_ADDRESS}"
|
||||
|
|
20
until/env.go
20
until/env.go
|
@ -1,8 +1,22 @@
|
|||
package until
|
||||
|
||||
import "os"
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func GetConfig() string {
|
||||
|
||||
return os.Getenv("GO_ENV")
|
||||
var dir string
|
||||
pwd, _ := os.Getwd()
|
||||
path := fmt.Sprintf("%s%s", pwd, "/../../env")
|
||||
bytes, _ := os.ReadFile(path)
|
||||
switch string(bytes) {
|
||||
case "produce":
|
||||
dir = "produce.yaml"
|
||||
case "test":
|
||||
dir = "test.yaml"
|
||||
default:
|
||||
dir = "local.yaml"
|
||||
}
|
||||
return dir
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue