no required module provides package fyne.io/fyne/app: go.mod file not found in current directory or any parent directory on intel mac

huangapple go评论87阅读模式
英文:

no required module provides package fyne.io/fyne/app: go.mod file not found in current directory or any parent directory on intel mac

问题

当尝试执行"go build"时,我遇到了以下错误:

没有所需的模块提供 fyne.io/fyne/app 包:在当前目录或任何父目录中找不到 go.mod 文件;请参阅"go help modules"
test.go:5:5: 没有所需的模块提供 fyne.io/fyne/widget 包:在当前目录或任何父目录中找不到 go.mod 文件;请参阅"go help modules"

但是我已经安装了 fyne.io/fyne,我不知道为什么会出现这个错误。我尝试重新安装 Go,但没有帮助。

no required module provides package fyne.io/fyne/app: go.mod file not found in current directory or any parent directory on intel mac

英文:

I'm getting this error when trying 'go build'

no required module provides package fyne.io/fyne/app: go.mod file not found in current directory or any parent directory; see 'go help modules'
test.go:5:5: no required module provides package fyne.io/fyne/widget: go.mod file not found in current directory or any parent directory; see 'go help modules'

But i'm installed fyne.io/fyne and i don't know why i have this mistake. I tried to reinstall Go but it's didn't help

no required module provides package fyne.io/fyne/app: go.mod file not found in current directory or any parent directory on intel mac

答案1

得分: 4

自Go 1.16版本开始,模块是必需的,因此您需要运行go mod init <项目名称>命令。
此外,请注意,对于Fyne,您现在应该使用v2的导入方式,即"fyne.io/fyne/v2"。您还应该从fyne.io/fyne/v2/cmd/fyne安装fyne工具。

英文:

Since Go 1.16 modules are required so you need to run go mod init &lt;project name&gt;.
Note also that for Fyne you should use the v2 imports now, which are ”fyne.io/fyne/v2”. And you should install the fyne tool from fyne.io/fyne/v2/cmd/fyne.

huangapple
  • 本文由 发表于 2021年9月9日 02:14:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/69107881.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定