我正在寻找在使用本地文件测试Golang时应该使用的最佳实践.
通过使用本地文件,我的意思是,为了测试功能,应用程序需要一些本地文件,因为应用程序经常从这些文件中读取.
我不确定是否应该在使用ioutil包tempdir和tempfile函数运行测试之前自己编写临时文件,或者创建一个类似的测试文件夹;
testing/...test_files_here
main.go
main_test.go
Run Code Online (Sandbox Code Playgroud)
然后从里面的内容中读取
testing/...
Run Code Online (Sandbox Code Playgroud)
谢谢