| Server IP : 217.160.0.212 / Your IP : 216.73.216.141 Web Server : Apache System : Linux www 6.18.51-i1-ampere #1196 SMP Fri Sep 11 20:43:55 CEST 2026 aarch64 User : sws1073854427 ( 1073854427) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/go/src/cmd/go/testdata/script/ |
Upload File : |
[short] skip
go test flag_test.go -v -args -v=7 # Two distinct -v flags
go test -v flag_test.go -args -v=7 # Two distinct -v flags
# Using a custom flag mixed with regular 'go test' flags should be OK.
go test -count=1 -custom -args -v=7
# However, it should be an error to use custom flags when -c is used,
# since we know for sure that no test binary will run at all.
! go test -c -custom
stderr '^go: unknown flag -custom cannot be used with -c$'
# The same should apply even if -c comes after a custom flag.
! go test -custom -c
stderr '^go: unknown flag -custom cannot be used with -c$'
-- go.mod --
module m
-- flag_test.go --
package flag_test
import (
"flag"
"log"
"testing"
)
var v = flag.Int("v", 0, "v flag")
var custom = flag.Bool("custom", false, "")
// Run this as go test pkg -v=7
func TestVFlagIsSet(t *testing.T) {
if *v != 7 {
log.Fatal("v flag not set")
}
}