问题现象
[root@centos7 test]# go run print_test.go
go run: cannot run *_test.go files (print_test.go)
这种以test结尾的文件名,go build也是不成功
问题原因
因为文件时test结尾,go认为时单元测试程序
解决方法
修改文件名,将test换成其他的单词即可
#重命名
[root@centos7 test]# mv print_test.go print_example.go
[root@centos7 test]# go run print_example.go
hello world!
[root@centos7 test]#