V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
xunle
V2EX  ›  Go 编程语言

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

  •  
  •   xunle · 2022-11-05 17:30:49 +08:00 · 1716 次点击
    这是一个创建于 543 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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 包一摸一样,搞不清白,求助 ┭┮﹏┭┮

    5 条回复    2022-11-06 00:38:03 +08:00
    wtfedc
        1
    wtfedc  
       2022-11-05 18:00:05 +08:00
    在包路径下,看看有没有 printer 包,有的话,检查下文件夹及文件权限
    xunle
        2
    xunle  
    OP
       2022-11-05 18:14:16 +08:00
    @wtfedc 有的
    xunle
        3
    xunle  
    OP
       2022-11-05 18:14:59 +08:00
    @wtfedc 权限是该用户 555
    dorothyREN
        4
    dorothyREN  
       2022-11-05 19:16:14 +08:00
    @xunle #3 改成 755 试试
    pennai
        5
    pennai  
       2022-11-06 00:38:03 +08:00
    一般都是 go 版本太老或者太新的问题,你去 github 看看缺少的那个包最多支持哪个版本,再看看它的 go.mod 版本
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   808 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 22:14 · PVG 06:14 · LAX 15:14 · JFK 18:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.