LoginSignup
1
1

More than 1 year has passed since last update.

Goのコンパイラバージョンアップ手順

Last updated at Posted at 2022-04-03

Goのコンパイラをバージョンアップする際の変更点やコマンドのメモです

バージョンアップ

go.modファイル

go.modでmodule管理している場合はgo mod editコマンドでgo.modファイルでのGoのバージョンを変更します。

以下のように1.17が指定されていたとして1.18に更新する場合は、

go.mod
module sample-app

go 1.17

次のコマンドを実行します。

$ go mod edit -go=1.18

再びgo.modファイルを確認すると1.18になっていることが確認できます

go.mod
module sample-app

go 1.18

Dockerfile

Dockerfileは手で書き換えます。

Dockerfile
- FROM golang:1.17.8-buster
+ FROM golang:1.18.0-buster

CI

circleci / github actionsの設定ファイルも手で書き換えます。

.circleci/config.yml
docker:
-  - image: golang:1.17.8-buster
+  - image: golang:1.18.0-buster
.github/workflows/go.yml
with:
-  go-version: 1.17
+  go-version: 1.18

動作確認

$ go version
go version go1.18 linux/arm64

docker-composeで開発している場合コンテナを削除して新しく作らないと古いコンテナを参照してしまいバージョンが更新されないケースがあるので注意してください。

$ docker-compose stop
$ docker-compose down
1
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1