fix: 更新数据库密码并移除废弃的env加载代码

This commit is contained in:
zhouyonggao 2025-11-27 16:57:48 +08:00
parent c7a313c7b5
commit 911c1bbc8a
2 changed files with 1 additions and 46 deletions

View File

@ -10,5 +10,5 @@ app:
host: "47.97.27.195" host: "47.97.27.195"
port: "3306" port: "3306"
user: "root" user: "root"
password: "lansexiongdi," password: "lansexiongdi6,"
name: "merketing" name: "merketing"

View File

@ -1,45 +0,0 @@
package config
import (
"bufio"
"os"
"path/filepath"
"strings"
)
func LoadEnv() {
paths := []string{
".env.local",
filepath.Join("server", ".env.local"),
}
for _, p := range paths {
if loadFile(p) {
return
}
}
}
func loadFile(path string) bool {
f, err := os.Open(path)
if err != nil {
return false
}
defer f.Close()
s := bufio.NewScanner(f)
for s.Scan() {
line := strings.TrimSpace(s.Text())
if line == "" || strings.HasPrefix(line, "#") {
continue
}
idx := strings.Index(line, "=")
if idx <= 0 {
continue
}
k := strings.TrimSpace(line[:idx])
v := strings.TrimSpace(line[idx+1:])
if _, ok := os.LookupEnv(k); !ok || os.Getenv(k) == "" {
os.Setenv(k, v)
}
}
return true
}