背景:
使用jenkins集成sonarQube对项目代码进行扫描,在统计go代码覆盖率时结果上报到sonarQube为0,
报错内容:File ‘xxx/xxx.go‘ is not included in the project, ignoring coverage
过程:
1.go单元测试生成cover.out文件
go test -v ./... -coverprofile=cover.out
2.sonar-scanner扫描
sonar-scanner -X -Dsonar.go.coverage.reportPaths=coverage.out
解决方法:
1.在sonar-scanner扫描之前先设置GOPATH
export GOPATH=$WORKSPAC