为了账号安全,请及时绑定邮箱和手机立即绑定

golang: 构建命令行参数: 找不到路径 x 的模块

golang: 构建命令行参数: 找不到路径 x 的模块

Go
拉莫斯之舞 2022-09-26 19:37:18
我在 main.go 中从非主包运行函数时遇到问题// main.gopackage mainimport test "./tests"func main() {    test.Test("hello world")}// (relative to main.go) ./tests/test.gopackage testimport "fmt"func Test(str string) {    fmt.Println(str)}输出:build command-line-arguments: cannot find module for path _/c_/Users/Mike/Desktop/random/tests 
查看完整描述

1 回答

?
不负相思意

TA贡献1777条经验 获得超10个赞

如果您使用的是 Go 1.16+,请使用 Go 模块:

  1. 执行go mod init projectname

  2. 替换为import test "./tests"import test "projectname/tests"


查看完整回答
反对 回复 2022-09-26
  • 1 回答
  • 0 关注
  • 92 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号