Google App Engine で Go App が No Go file とエラーになるとき

app.yaml の場所に注目


Posted on Sat, Jan 26, 2019
Tags golang, gae

gcloud app deploy で No Go file になった

go-zen-chu/gae-fitbit-go: GAE App to fetch data from fitbit in golang を開発中のことである。

プロジェクトのルートディレクトリに app.yaml を配置して、デプロイをしてみた。

$ gcloud app deploy

------------------------------------ STDOUT ------------------------------------
building with dependencies from GOPATH
------------------------------------ STDERR ------------------------------------
2019/01/26 18:27:07 staging for go1.11
main-package: github.com/go-zen-chu/gae-fitbit-go
2019/01/26 18:27:07 Staging second-gen Standard app: failed analyzing /Users/amasuda/go/src/github.com/go-zen-chu/gae-fitbit-go: could not get package for dir "/Users/amasuda/go/src/github.com/go-zen-chu/gae-fitbit-go": no buildable Go source files in /Users/amasuda/go/src/github.com/go-zen-chu/gae-fitbit-go
GOPATH: /Users/amasuda/go:
--------------------------------------------------------------------------------

GOPATH は正しいし、普段 cloud foundry を使っている自分は、manifest.yml をプロジェクトのルートディレクトリに配置していたので、しばらく何でだろうと調べていた。

サンプル App もルートディレクトリに置いてるしなぁ。 golang-samples/appengine/helloworld at master · GoogleCloudPlatform/golang-samples

結論

なんてことはない。app.yaml の配置場所を main.go の隣にすれば良かった。

gae-fitbit-go/app/gae-fitbit-go

ちなみに

Go 1.11 が使えるようなので使ってみた。

Announcing App Engine’s New Go 1.11 Runtime - The Go Blog