current file is not included in a workspace moduleg 存在多个 main函数的 Go项目 无法成功导包

编程入门 行业动态 更新时间:2024-10-18 22:34:37

current file is not included in a workspace moduleg 存在<a href=https://www.elefans.com/category/jswz/34/1771377.html style=多个 main函数的 Go项目 无法成功导包"/>

current file is not included in a workspace moduleg 存在多个 main函数的 Go项目 无法成功导包

报错缘由

学习 hystria, 尝试自测案例,使用了
go get “github/afex/hystrix-go/hystrix” 进行导入包,
导入成功后,在代码里利用 import 导入,但遇到了以下报错

could not import github/afex/hystrix-go/hystrix (current file is not included in a workspace module)

项目的层次结构如下:
注: gopro 作为程序的根目录,hystrix 作为子目录,并且均使用 go mod init 命令对 gopro, hystrix 做了项目的初始化。

解决方法

在项目的根目录利用 go get 命令进行所需包的导入
(一开始仅对 hystrix 子目录进行了 go get 的导入)

更多推荐

current file is not included in a workspace moduleg 存在多个 main函数的 Go项目 无法成功导包

本文发布于:2023-12-03 11:12:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1654724.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   函数   项目   included   file

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!