はじめに
こちらは、go.modのパースに関するエラーです。
コマンド以外ではgo.modを触っていなかったために対処法が分からず苦労したので、バグレポートのような感じで残しておきます。
原因と対処法
原因は、go.mod内で記述するgoのバージョン指定方法に誤りがあるためでした。
go.mod
module hoge
go 1.21.3 // ここが原因(バージョン指定方法ミス)
require (
...
)
そのため、以下の記述方法に変更します。
go.mod
module hoge
go 1.21 // 変更
require (
...
)
そうすると、エラーが発生せずに動かすことができました。