It can sometimes be cumbersome using well known Build Tags feature in Go applications to differentiate and run certain tests. For example you will sometimes repeat tags in many files so on. Instead of going such direction, as a workaround you can rely on a regex pattern. For instance, what I do here is that, I prefix all my integration tests with Test_int_. The test command then will use a regex rather than build tags.


func Test_int_CreateUser(t *testing.T) { ... }

go test -race -run '^([^T]|T($|[^e]|e($|[^s]|s($|[^t]|t($|[^_]|_($|[^i]|i($|[^n]|n($|[^t]|t($|[^_]))))))))).*' ./...

If you break it down, result is this.


^
([^T]|T
($|[^e]|e
($|[^s]|s
($|[^t]|t
($|[^_]|_
($|[^i]|i
($|[^n]|n
($|[^t]|t
($|[^_])
)
)
)
)
)
)
)
)
.*