...

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

Documentation: cmd/go/testdata/script

     1# go.dev/issue/65612
     2# go vet should set the GoVersion for command line files.
     3
     4env TESTGO_VERSION=go1.22.1
     5env TESTGO_VERSION_SWITCH=switch
     6
     7go vet -n -json example.com/m
     8stderr '"GoVersion": "go1.22.0"'
     9
    10# A command line file should use the local go version.
    11go vet -n -json main.go
    12stderr '"GoVersion": "go1.22.1"'
    13
    14# In workspace mode, the command line file version should use go.work version.
    15cp go.work.orig go.work
    16go vet -n -json example.com/m
    17stderr '"GoVersion": "go1.22.0'
    18
    19go vet -n -json main.go
    20stderr '"GoVersion": "go1.22.2'
    21
    22# Without go.mod or go.work, the command line file version should use local go version .
    23env TESTGO_VERSION=go1.22.3
    24rm go.mod
    25rm go.work
    26
    27! go vet -n -json example.com/m
    28
    29go vet -n -json main.go
    30stderr '"GoVersion": "go1.22.3"'
    31
    32-- go.mod --
    33module example.com/m
    34
    35go 1.22.0
    36
    37-- go.work.orig --
    38go 1.22.2
    39
    40use .
    41
    42-- main.go --
    43package main

View as plain text