go 新手,为啥这个导包会报错啊/(ㄒoㄒ)/~~

2022-11-05 17:30:49 +08:00
 xunle
ubuntu@ubuntu:~$ go mod tidy
...
go: finding module for package github.com/hashicorp/hcl/json/parser
go: finding module for package github.com/hashicorp/hcl/hcl/printer
go: finding module for package github.com/hashicorp/hcl/hcl/ast
go: finding module for package github.com/hashicorp/hcl/hcl/parser
...
github.com/spf13/viper imports github.com/spf13/viper/internal/encoding/hcl imports github.com/hashicorp/hcl/hcl/printer: module github.com/hashicorp/hcl@latest found (v1.0.0), but does not contain package github.com/hashicorp/hcl/hcl/printer
...
ubuntu@ubuntu:~$ go env
GO111MODULE="on"
...
GOVERSION="go1.19.2"

最离谱的是 root 用户使用 go mod tidy 没问题,但两个用户 GOPATH 下导的 hcl 包一摸一样,搞不清白,求助 ┭┮﹏┭┮

1745 次点击
所在节点    Go 编程语言
5 条回复
wtfedc
2022-11-05 18:00:05 +08:00
在包路径下,看看有没有 printer 包,有的话,检查下文件夹及文件权限
xunle
2022-11-05 18:14:16 +08:00
@wtfedc 有的
xunle
2022-11-05 18:14:59 +08:00
@wtfedc 权限是该用户 555
dorothyREN
2022-11-05 19:16:14 +08:00
@xunle #3 改成 755 试试
pennai
2022-11-06 00:38:03 +08:00
一般都是 go 版本太老或者太新的问题,你去 github 看看缺少的那个包最多支持哪个版本,再看看它的 go.mod 版本

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/892938

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX