mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
switch current working dir to the resource dir of the executable
This commit is contained in:
parent
ea27a291db
commit
7c1e74b3a8
|
@ -5,6 +5,7 @@ import (
|
|||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
|
@ -18,8 +19,18 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
dotenvFile := ".env.local"
|
||||
ep, err := os.Executable()
|
||||
if err != nil {
|
||||
log.Fatalln("failed to find the current executable:", err)
|
||||
}
|
||||
|
||||
err = os.Chdir(filepath.Join(filepath.Dir(ep), "..", "Resources"))
|
||||
if err != nil {
|
||||
log.Fatalln("chdir error:", err)
|
||||
}
|
||||
|
||||
|
||||
dotenvFile := ".env.local"
|
||||
if _, err := os.Stat(dotenvFile) ; err == nil {
|
||||
if err := godotenv.Load(dotenvFile); err != nil {
|
||||
log.WithError(err).Error("error loading dotenv file")
|
||||
|
|
Loading…
Reference in New Issue
Block a user