集成测试,通配符忽略标签

I would like to separate my integration tests from the unit tests. I have read that I can do it including tags in the test file:

// +build integration

On the other hand, I select all the packages from my project by using wildcards ./...

Unfortunately, I have problems, tags are ignored because of the wildcard.

go test ./... -tags=integration

or

go test -tags=integration ./...

Do you have any solution or alternative to it?

Within your integration tests you can use:

func Test_SomeIntegration(t *testing.T) {
    if testing.Short() {
      t.Skip("skipping test")
    }
    ...
}

And then pass -short flag to the go test command to skip integration tests:

go test -short ./...