Sunday, August 23, 2020

Skipping Go Race detector for some packages

  

In my previous post, I covered the basics of Go Race detector. In most Golang, projects, we would have multiple projects. 

For some reason, if we want to skip race detector for some packages, we can use this option as the first line of the package & an empty second line:

// +build !race


I ran the sample code on my github with the above option to get this:
Babus-MacBook-Pro:Race_Tests_inGolang babuneelam$ go build -race
package racetest: build constraints exclude all Go files in /Users/babuneelam/Projects/GoProjects/Race_Tests_inGolang
Babus-MacBook-Pro:Race_Tests_inGolang babuneelam
I have only a single package in this, so this error. If I were to have multiple packages in this repository, it would have build those.

1 comment:

Infosec Train said...

This is so helpful!! Thanks for this article

UA-48797665-1