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

     1  # Test for issue #68658: In GOPATH mode, files with a //go:build fileVersion
     2  # earlier than go1.21 should downgrade to go1.21 and no further.
     3  
     4  [short] skip 'requires build'
     5  
     6  env GO111MODULE=off
     7  go build foo bar
     8  
     9  -- foo/main.go --
    10  //go:build go1.10
    11  
    12  package p
    13  
    14  import "fmt"
    15  
    16  func main() {
    17  	var x any  // any was added in Go 1.18
    18  	fmt.Println(x)
    19  }
    20  
    21  -- bar/main.go --
    22  //go:build go1.20
    23  
    24  package p
    25  
    26  import "fmt"
    27  
    28  func main() {
    29      y := max(1, 2)  // max was added in Go 1.21
    30      fmt.Println(y)
    31  }
    32  

View as plain text