Skip to content

Commit e13a552

Browse files
committed
<feature>增加自動讀取現行目錄下的envfile功能,方便CLI使用者啟動
1 parent 8a6f824 commit e13a552

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

apps/frontend/server.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ func mkSlice(args ...interface{}) []interface{} {
1717
}
1818

1919
func main() {
20-
if err := godotenv.Load("envfile"); err != nil {
21-
fmt.Println("Error loading .env file")
20+
currentDir, err := os.Getwd()
21+
if err != nil {
22+
fmt.Println(err.Error())
23+
return
24+
}
25+
if err := godotenv.Load(currentDir + "/envfile"); err != nil {
26+
fmt.Println(err.Error())
2227
return
2328
}
2429
port := os.Getenv("PORT")

0 commit comments

Comments
 (0)