概要 docker-composeを用いた複数コンテナを利用していました。 このうちの1つがgolangで作成したapiだったのですが、このapiにgo modulesを導入しようとして少しハマったので解決策を共有します。 そもそもgo moduleとは 一応前提の話をしますと、go modulesを使うことによって$GOPATHを気にすることなくpackageをimportすることができるようになります。 package mainだけで完結している軽いアプリケーションなら不要ですが、packageを分割したい際にはgo moduleを導入するといいかもしれません。 スタック フォルダ構成 article ├ client ├ api │ ├ main.go │ ├ // 省略 │ ├ go.mod │ ├ go.sum │ └ Dockerfile ├ nginx └ docker-co