0
0

More than 1 year has passed since last update.

golangでimportできない問題解決

Posted at

どんなことが起きていたか

config.goでutilsをimportしようとしたが、階層を指定しても読み込まれなかった。
二枚目の画像の5行目がimportできなかった。

解決方法

①Go Modulesの初期化
go mod init [モジュール名]でGo Modulesの初期化をする。
作業ディレクトリ作成直後に初期化した。

go mod init [作業ファイル名]
go mod init go-example

以下のように、go.modファイルが作成される。

module go-example

go 1.16

これでimportできるようになった。

参考文献

0
0
0

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
0
0