Reputation: 187
In one of my deployed app engines I am getting the following error.
error loading config file: open go-config.json: no such file or directory
This is the snippet of go code in handlers.go
config := config{}
err := gonfig.GetConf("go-config.json", &config)
if err != nil {
log.Printf("error loading config file: %v\n", err)
}
This is my app.yaml
file
runtime: go114
service: finance
On the debugger for the app engine I can see that the project structure looks like this.
app engine:/
quantify
app.yaml
config.go
go-config.json
main.go
handlers.go
quantify
Why cant I read this file in my deployed application code? I've tried specifying handlers in my app.yaml
a number of ways with no success.
Upvotes: 1
Views: 448
Reputation: 389
first you should find out the current path by fmt.Println(os.Getwd())
fmt.Println(os.Getwd())
config := config{}
err := gonfig.GetConf("go-config.json", &config)
if err != nil {
log.Printf("error loading config file: %v\n", err)
}
then change "go-config.json" to a relarate path to the current path
Upvotes: 1