func TestMyFunction(t *testing.T) { if !someCondition { t.Skip("Skipping this test because of some condition") } // Normal test code here }
func TestMyFunction(t *testing.T) { if os.Getenv("SKIP_MY_TEST") != "" { t.Skip("Skipping this test because SKIP_MY_TEST environment variable is set") } // Normal test code here }In this example, we check for a specific environment variable and skip the test if it's set. The `testing.T.Skip` function is part of the built-in `testing` package in Go.