验证码: 看不清楚,换一张 查询 注册会员,免验证
  • {{ basic.site_slogan }}
  • 打开微信扫一扫,
    您还可以在这里找到我们哟

    关注我们

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

阅读:274 来源:乙速云 作者:代码code

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  [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 " for more information about a command.

      GO111MODULE=on

      export GOPROXY=https://goproxy.io

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

      go mod tidy

    分享到:
    *特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: hlamps#outlook.com (#换成@)。
    相关文章
    {{ v.title }}
    {{ v.description||(cleanHtml(v.content)).substr(0,100)+'···' }}
    你可能感兴趣
    推荐阅读 更多>