• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Go设置工作区打开多个项目

武飞扬头像
梦实现了吗
帮助1

在vscode使用go的时候,如果没有在gopath下运行,可能会出现

Error message "go: go.mod file not found in current directory or any parent directory; see 'go help modules'"

或者

"Error loading workspace: You are outside of a module and outside of $GOPATH/src. If you are using modules, please 
open your editor to a directory in your module. If you believe this warning is incorrect, please file an issue:
https://github.com/golang/go/issues/new."

虽然不会有什么影响,但是看起来很烦。

在早期的版本中(go 1,17及以前),可以通过在setting.json中添加

"gopls": {
    "experimentalWorkspaceModule": true,
}

如果是1.18以后的版本,可以使用go work

在工作区的根目录下运行

go work init
go work use [floder-name] 

学新通
比如我的目录是这样的结构。就可以运行

go work use gin1  // Or go work use .\gin1\

如果有在目录下有多个文件夹,可以使用

go work use -r [floder-name] 

来遍历目录下所有文件夹

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgfibaj
系列文章
更多 icon
同类精品
更多 icon
继续加载