写在前面的话: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执行就可以了,如下图
