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

     1  # Regression test for https://go.dev/issue/52331: 'go run -mod=mod'
     2  # failed to write go.mod and go.sum with the resolved dependencies.
     3  
     4  [short] skip
     5  
     6  ! go run main.go
     7  # stderr '^main\.go:6:2: no required module provides package example\.com/version; to add it:\n\tgo get example\.com/version\n\z'
     8  
     9  go run -mod=mod main.go
    10  cmp go.mod go.mod.want
    11  grep -count=1 '^example\.com/version v1.1.0 h1:' go.sum
    12  grep -count=1 '^example\.com/version v1.1.0/go.mod h1:' go.sum
    13  
    14  -- go.mod --
    15  module example
    16  
    17  go 1.17
    18  -- go.mod.want --
    19  module example
    20  
    21  go 1.17
    22  
    23  require example.com/version v1.1.0 // indirect
    24  -- main.go --
    25  package main
    26  
    27  import (
    28  	"fmt"
    29  
    30  	"example.com/version"
    31  )
    32  
    33  func main() {
    34  	fmt.Println(version.V)
    35  }
    36  

View as plain text