锻炼 来自实践问题解决方案 要对所有软件包运行测试,只需运行以下命令: go test -v -bench . -benchmem ./... 要运行CPU和内存配置文件,请使用cpuprofile和memprofile标志运行测试。 # Assuming we are already in the directory with go.mod for package in $( find go -maxdepth 1 -mindepth 1 -type d ) do go test -v -bench . -benchmem -cpuprofile ${dir} /cpu.out