在云外壳中运行go run main.go而不部署应用程序引擎,返回错误

时间:2020-04-06 11:12:22

标签: shell go google-app-engine cloud gcloud

我正在使用应用程序引擎部署REST API

当我使用gcloud应用程序部署时,该API可以正常运行。但是,我希望能够通过使用

来测试我的go代码而无需进行部署
go run main.go 

但是,当我运行它时出现此错误

panic: Metadata fetch failed for 'instance/attributes/gae_backend_version': metadata server returned HTTP 404

goroutine 66 [running]:
google.golang.org/appengine/internal.mustGetMetadata(0xac3a19, 0x27, 0x0, 0x0, 0x1d)
        /google/gopath/src/google.golang.org/appengine/internal/metadata.go:34 +0x148
google.golang.org/appengine/internal.VersionID(0x0, 0x0, 0xaaafac, 0x1)
        /google/gopath/src/google.golang.org/appengine/internal/identity_vm.go:91 +0x100
google.golang.org/appengine/internal.DefaultTicket.func1()
        /google/gopath/src/google.golang.org/appengine/internal/api.go:299 +0x13f
sync.(*Once).doSlow(0xffb060, 0xad9bb8)
        /usr/local/go/src/sync/once.go:66 +0xe3
sync.(*Once).Do(...)
        /usr/local/go/src/sync/once.go:57
google.golang.org/appengine/internal.DefaultTicket(0xc0002c8240, 0x971640)
        /google/gopath/src/google.golang.org/appengine/internal/api.go:292 +0x65
google.golang.org/appengine/internal.Call(0xb80880, 0xc0002c8240, 0xab04b5, 0xa, 0xaabd4e, 0x5, 0xb7c080, 0xc00028a1c0, 0xb7b280, 0xc00044e080, ...)
        /google/gopath/src/google.golang.org/appengine/internal/api.go:499 +0x907
google.golang.org/appengine/internal.(*context).flushLog(0xc0002502a0, 0x1, 0x0)
        /google/gopath/src/google.golang.org/appengine/internal/api.go:644 +0x419
google.golang.org/appengine/internal.handleHTTP.func1(0xc000468180, 0xc0002502a0)
        /google/gopath/src/google.golang.org/appengine/internal/api.go:141 +0x60
created by google.golang.org/appengine/internal.handleHTTP
        /google/gopath/src/google.golang.org/appengine/internal/api.go:137 +0x38c
exit status 2

此链接 https://groups.google.com/forum/#!topic/google-appengine-go/Fd8DxpzEoVs 说要添加appengine.Main()到已经添加的主函数中

0 个答案:

没有答案