在我部署的一个应用程序引擎中,我得到了以下错误。
error loading config file: open go-config.json: no such file or directory
这是handlers.go中的go代码片段
config := config{}
err := gonfig.GetConf("go-config.json", &config)
if err != nil {
log.Printf("error loading config file: %v\n", err)
}这是我的app.yaml文件
runtime: go114
service: finance在应用程序引擎的调试器上,我可以看到项目结构如下所示。
app engine:/
quantify
app.yaml
config.go
go-config.json
main.go
handlers.go
quantify为什么我无法在已部署的应用程序代码中读取此文件?我已经尝试了很多种在app.yaml中指定处理程序的方法,但都没有成功。
发布于 2020-10-21 10:06:27
首先,你应该通过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)
}然后将"go-config.json“更改为当前路径的相对路径
https://stackoverflow.com/questions/64455222
复制相似问题