...

Text file src/cmd/go/testdata/script/godebug_default.txt

Documentation: cmd/go/testdata/script

     1env GO111MODULE=on
     2env GOTRACEBACK=single
     3
     4# Go 1.21 work module should leave panicnil with an implicit default.
     5cp go.mod.21 go.mod
     6go list -f '{{.Module.GoVersion}} {{.DefaultGODEBUG}}'
     7! stdout panicnil
     8stdout randautoseed=0
     9
    10# Go 1.21 work module should NOT set panicnil=1 in Go 1.20 dependency.
    11cp go.mod.21 go.mod
    12go list -f '{{.Module.GoVersion}} {{.DefaultGODEBUG}}' q
    13! stdout panicnil=1
    14! stdout randautoseed
    15
    16go mod download rsc.io/panicnil # for go.sum
    17go list -f '{{.Module.GoVersion}} {{.DefaultGODEBUG}}' rsc.io/panicnil
    18! stdout panicnil=1
    19! stdout randautoseed
    20
    21# Go 1.20 work module should set panicnil=1.
    22cp go.mod.20 go.mod
    23go list -f '{{.Module.GoVersion}} {{.DefaultGODEBUG}}'
    24stdout panicnil=1
    25stdout randautoseed=0
    26
    27# Go 1.20 work module should set panicnil=1 in Go 1.20 dependency.
    28cp go.mod.20 go.mod
    29go list -f '{{.Module.GoVersion}} {{.DefaultGODEBUG}}' q
    30stdout panicnil=1
    31! stdout randautoseed
    32
    33# Go 1.21 workspace should leave panicnil with an implicit default.
    34cat q/go.mod
    35cp go.work.21 go.work
    36go list -f '{{.Module.GoVersion}} {{.DefaultGODEBUG}}'
    37! stdout panicnil
    38stdout randautoseed=0
    39rm go.work
    40
    41# Go 1.20 workspace with Go 1.21 module cannot happen.
    42cp go.work.20 go.work
    43cp go.mod.21 go.mod
    44! go list -f '{{.Module.GoVersion}} {{.DefaultGODEBUG}}'
    45stderr 'go: module . listed in go.work file requires go >= 1.21'
    46rm go.work
    47
    48# Go 1.21 go.mod with godebug default=go1.20
    49rm go.work
    50cp go.mod.21 go.mod
    51go mod edit -godebug default=go1.20 -godebug asynctimerchan=0
    52go list -f '{{.Module.GoVersion}} {{.DefaultGODEBUG}}'
    53stdout panicnil=1
    54stdout asynctimerchan=0
    55
    56# Go 1.21 go.work with godebug default=go1.20
    57cp go.work.21 go.work
    58go list -f '{{.Module.GoVersion}} {{.DefaultGODEBUG}}'
    59! stdout panicnil # go.work wins
    60stdout asynctimerchan=1 # go.work wins
    61go work edit -godebug default=go1.20 -godebug asynctimerchan=0
    62go list -f '{{.Module.GoVersion}} {{.DefaultGODEBUG}}'
    63stdout panicnil=1
    64stdout asynctimerchan=0
    65rm go.work
    66
    67# Go 1.21 go.mod with //go:debug default=go1.20 in program
    68cp go.mod.21 go.mod
    69go list -tags godebug -f '{{.Module.GoVersion}} {{.DefaultGODEBUG}}'
    70stdout panicnil=1
    71stdout asynctimerchan=0
    72
    73# Invalid //go:debug line should be diagnosed at build.
    74! go build -tags godebugbad
    75stderr 'invalid //go:debug: value contains space'
    76
    77[short] skip
    78
    79# Programs in Go 1.21 work module should trigger run-time error.
    80cp go.mod.21 go.mod
    81! go run .
    82stderr 'panic: panic called with nil argument'
    83
    84! go run rsc.io/panicnil
    85stderr 'panic: panic called with nil argument'
    86
    87# Programs in Go 1.20 work module use old panic nil behavior.
    88cp go.mod.20 go.mod
    89! go run .
    90stderr 'panic: nil'
    91
    92! go run rsc.io/panicnil
    93stderr 'panic: nil'
    94
    95# Programs in no module at all should use their go.mod file.
    96rm go.mod
    97! go run rsc.io/panicnil@v1.0.0
    98stderr 'panic: nil'
    99
   100rm go.mod
   101! go run rsc.io/panicnil@v1.1.0
   102stderr 'panic: panic called with nil argument'
   103
   104-- go.work.21 --
   105go 1.21
   106use .
   107use ./q
   108
   109-- go.work.20 --
   110go 1.20
   111use .
   112use ./q
   113
   114-- go.mod.21 --
   115go 1.21
   116module m
   117require q v1.0.0
   118replace q => ./q
   119require rsc.io/panicnil v1.0.0
   120
   121-- go.mod.20 --
   122go 1.20
   123module m
   124require q v1.0.0
   125replace q => ./q
   126require rsc.io/panicnil v1.0.0
   127
   128-- p.go --
   129//go:debug randautoseed=0
   130
   131package main
   132
   133func main() {
   134	panic(nil)
   135}
   136
   137-- godebug.go --
   138//go:build godebug
   139//go:debug default=go1.20
   140//go:debug asynctimerchan=0
   141
   142package main
   143
   144-- godebugbad.go --
   145//go:build godebugbad
   146//go:debug default=go1.20 asynctimerchan=0
   147
   148package main
   149
   150-- q/go.mod --
   151go 1.20
   152module q
   153
   154-- q/q.go --
   155package main
   156func main() {}

View as plain text