missing API definition, make sure design.Design is properly initialized
私もすでに2つの環境で遭遇し、さすがに学習しなさすぎなので記録を残すことにしました。
使用したソースコード
gormaのサンプル環境で行いました。https://github.com/goadesign/gorma-cellar
generate.sh の pkg-path をgormaをフォークしたものに変更して、generate.shを実行しました。
$ sh generate.sh app app/contexts.go app/controllers.go app/hrefs.go app/media_types.go app/user_types.go app/test app/test/account_testing.go app/test/bottle_testing.go app/test/health_testing.go app/test/js_testing.go app/test/public_testing.go app/test/swagger_testing.go tool/cli tool/cli/commands.go client client/client.go client/account.go client/bottle.go client/health.go client/js.go client/public.go client/swagger.go client/user_types.go client/media_types.go swagger swagger/swagger.json swagger/swagger.yaml js js/client.js js/axios.min.js js/index.html js/example.go schema schema/schema.json exit status 1 missing API definition, make sure design.Design is properly initialized
原因
読んで字の如く、design.Designが初期化されていないエラー。対処
- vendorディレクトリを自gormaディレクトリ内に作らない。
- golangではvendorディレクトリ以下を優先的にimportする仕様。そのため呼び出し元のdesign.Designとgormaのdesign.Designが異なるという現象が発生する。
参考URL:https://golang.org/cmd/go/#hdr-Vendor_Directories