针对邮乐的修改

This commit is contained in:
Rzy 2024-07-16 18:54:13 +08:00
parent 93d95254b7
commit a7664d5ed2
6 changed files with 22 additions and 7 deletions

View File

@ -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()

1
env Normal file
View File

@ -0,0 +1 @@
produce

View File

@ -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

View File

@ -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

View File

@ -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}"

View File

@ -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
}