【Go学习】macOS+IDEA运行golang项目,报command-line-arguments,undefined

写在前面的话:idea如何配置golang,自行百度

问题1:通过idea的terminal执行go test报错

在这里插入图片描述

✘ xxxxx@macdeMacBook-Pro-3  /Volumes/mac/.../LearnGoWithTests/hello  go test
go: go.mod file not found in current directory or any parent directory; see 'go help modules'

这个问题就是当前目录没有go.mod文件,直接用go命令生成一个即可(example.com/m 可以随便自定义,比如:helloWorld)

✘ xxxxx@macdeMacBook-Pro-3  /Volumes/mac/.../LearnGoWithTests/hello  go mod init example.com/m      
go: creating new go.mod: module example.com/m
go: to add module requirements and sums:
        go mod tidy

再次执行go test就没问题了(下面的虽然case FAIL了,但是执行是没问题的)

✘ xxxxx@macdeMacBook-Pro-3  /Volumes/mac/.../LearnGoWithTests/hello  go test
PASS
ok      example.com/m   0.470s
问题2:通过idea的Run或Debug执行,就会报command-line-arguments,undefined

在这里插入图片描述
【解决方法】打开preferences,如下图设置一下即可
在这里插入图片描述
在这里插入图片描述
然后再用Run或Debug执行就可以了,如下图
在这里插入图片描述

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-17 16:42:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-17 16:42:04       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-17 16:42:04       82 阅读
  4. Python语言-面向对象

    2024-01-17 16:42:04       91 阅读

热门阅读

  1. Qt之QxOrm

    2024-01-17 16:42:04       54 阅读
  2. Python装饰器

    2024-01-17 16:42:04       58 阅读
  3. uniapp导航栏组件如何使用

    2024-01-17 16:42:04       56 阅读
  4. C++中的面向对象设计模式实践

    2024-01-17 16:42:04       57 阅读
  5. Spring整理-Spring框架中用了哪些设计模式

    2024-01-17 16:42:04       57 阅读
  6. Centos常用命令整理,常用的比较全了

    2024-01-17 16:42:04       47 阅读
  7. MyISAM 和 InnoDB 如何选择?

    2024-01-17 16:42:04       54 阅读
  8. iTMSTransporter上传ipa文件

    2024-01-17 16:42:04       63 阅读