温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

goland中导包报红和go mod问题怎么解决

发布时间:2023-03-07 17:17:50 来源:亿速云 阅读:216 作者:iii 栏目:开发技术

这篇文章主要介绍了goland中导包报红和go mod问题怎么解决的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇goland中导包报红和go mod问题怎么解决文章都会有所收获,下面我们一起来看看吧。

    goland导包报红

    1. 原理

    import的包有两类:

    (1)在go.mod中有地址的,这种需要拉到gopath/pkg下

    (2)没在go.mod的,这种在项目里,import的路径需要从path路径(即:/go/src/,gopath为go寻找的根路径)为根路径可以找到的:import github.com/CardInfoLink/quickpay/internal/ins,对应项目所在路径:/go/src/github.com/CardInfoLink/quickpay

    2. 以前的笔记

    goland中导包报红和go mod问题怎么解决

    goland中导包报红和go mod问题怎么解决

    要打开项目的直接目录:trunk

    若打开上级的话则报红

    可能有关这些配置文件的原因

    go mod

    go mod tidy 

    goland 还是报红的话 goland Preference->Go->Go Modules(vgo) -> Enable Go Modules(vgo)intergration

    jrw@wangfy:~/code/community/article$ go mod
    Go mod provides access to operations on modules.
     
    Note that support for modules is built into all the go commands,
    not just 'go mod'. For example, day-to-day adding, removing, upgrading,
    and downgrading of dependencies should be done using 'go get'.
    See 'go help modules' for an overview of module functionality.
     
    Usage:
     
            go mod <command> [arguments]
     
    The commands are:
     
            download    download modules to local cache
            edit        edit go.mod from tools or scripts
            graph       print module requirement graph
            init        initialize new module in current directory
            tidy        add missing and remove unused modules
            vendor      make vendored copy of dependencies
            verify      verify dependencies have expected content
            why         explain why packages or modules are needed
     
    Use "go help mod <command>" for more information about a command.

    GO111MODULE=on

    export GOPROXY=https://goproxy.io

    sudo chmod -R 777  /工作目录 (-R:是指几连医用到目录里所有子目录和文件;777:是指所有用户都拥有的最高权限)

    go mod tidy

    关于“goland中导包报红和go mod问题怎么解决”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“goland中导包报红和go mod问题怎么解决”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注亿速云行业资讯频道。

    向AI问一下细节

    免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

    AI