gcpug / nouhau

Google Cloud Platformのノウハウを共有するRepository
https://gcpug.jp
MIT License
653 stars 23 forks source link

Go 1.9 migration to Go 1.11 で嬉しいこと悲しいこと #76

Closed sinmetal closed 5 years ago

sinmetal commented 5 years ago

WHAT

Google App Engine Standard 1.9 (1st generation) から 1.11 (2nd generation) に移行すると、何が嬉しくて何が悲しいかを記す

WHY

Go 1.9 から Go 1.11に移行する時に何を考えるべきかをまとめる

sinmetal commented 5 years ago

WIP...

嬉しい

Socket API, URL Fetch APIからの脱却

1st genでは、App Engine SDK以外のCloud Serviceたちを利用する場合、REST APIではURL Fetch API, gRPCではSocket APIを利用していたが、2nd genでは使わなくてよくなった。

Spannerに接続できる

1st genでは繋げなかったCloud Spannerに繋げるようになった。

悲しい

User Serviceの終焉

login:required, login: admin は廃止となった。 移行先としてはIdentity Aware Proxyが考えられるが、AllUsersが指定できないのと、Request Pathが指定できないのが難点。 Request PathはIdentity Aware Proxy Conditionで解消できる可能性があり。

LogがRequestごとにまとめられなくなった

contextがなくても、fmt.Println() とかで標準出力に出力すればLogが出力できるようになったが、代わりにRequestごとにLogがまとめられず、すべてばらばらに表示されるようになった。 これは根性入れれば、なんとかできる可能性がある。

localとproductionで、working dirが変わることがある

dev_appserver.py は app.yamlがある場所をworking dirとして利用する。 そのため、 ./html/index.html をApplicationで呼んでると、 app.yaml がある場所から見ていく。 Go 1.9ではProductionでもこの挙動だった。

Go 1.11で go modulesを利用する場合、 go.mod がある場所がworking dirになる。 そのため、top dirに app.yaml, go.modがある場合は問題がないが、階層を掘っているとlocalとproductionでworking dirが別の場所になってしまう。

移行先まとめ