【发布时间】:2021-10-31 12:31:43
【问题描述】:
我正在使用以下 Go 模块来构建应用程序:
github.com/martinlindhe/unit
现在,Go 代码非常简单;我只是想为实际工作设置环境:
import(
"fmt"
"unit"
)
foo := unit.FromFahrenheit(100)
fmt.Println("100 fahrenheit in celsius = ", foo.Celsius())
在 go.mod 中:
go 1.17
require github.com/martinlindhe/unit v0.0.0-20210313160520-19b60e03648d
执行go build 或go get 会导致:
package unit is not in GOROOT (/usr/local/Cellar/go/1.17/libexec/src/unit)
运行go mod download 执行没有错误。 go.sum 文件似乎是正确的,所有必要的依赖项都存在。
环境是最新版本的VS Code,Go通过homebrew安装在MacOS Big Sur 11.5.2上
一定有一些明显的东西我错过了。我编写的其他应用程序没有这个问题。
【问题讨论】:
-
将其导入为“github.com/martinlindhe/unit”,而不仅仅是“unit”
-
啊哈!谢谢!昨晚我这样做太晚了。
标签: go