mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +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"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
|
@ -18,8 +19,18 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
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 := os.Stat(dotenvFile) ; err == nil {
|
||||||
if err := godotenv.Load(dotenvFile); err != nil {
|
if err := godotenv.Load(dotenvFile); err != nil {
|
||||||
log.WithError(err).Error("error loading dotenv file")
|
log.WithError(err).Error("error loading dotenv file")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user