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

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

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

bash 复制代码
✘ 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)

bash 复制代码
✘ 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了,但是执行是没问题的)

bash 复制代码
✘ 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 小时前
C# 字符串(String)详解
开发语言·后端·c#
精明的身影1 小时前
C++自学之路1:Hello world
开发语言·c++
leo__5202 小时前
基于导航数据的扩展卡尔曼滤波(EKF)MATLAB 实现
开发语言·matlab
gugucoding2 小时前
25. 【C语言】二进制文件与随机读写
c语言·开发语言
北极星日淘2 小时前
中古货品品相评级算法实战|Java权重计分实现标准化五级品相体系
开发语言·python
小巧的砖头2 小时前
C#会重蹈覆辙吗?系列之2:反射及元数据的性能问题
开发语言·前端·c#
凯瑟琳.奥古斯特2 小时前
力扣1009补码解法C++实现
开发语言·c++·算法·leetcode·职场和发展
2601_963645922 小时前
【2026最新】MATLAB教程(附安装包,非常详细)
开发语言·matlab·信息可视化
闲猫4 小时前
Python 虚拟环境 virtualenv & uvicorn 服务搭建 & FAstAPI 使用
开发语言·python
三月不知肉味y4 小时前
2026-07-05-JAVA面试场景题训练
java·开发语言·面试