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

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

View as plain text