...

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

Documentation: cmd/go/testdata/script

     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
     9go run -mod=mod main.go
    10cmp go.mod go.mod.want
    11grep -count=1 '^example\.com/version v1.1.0 h1:' go.sum
    12grep -count=1 '^example\.com/version v1.1.0/go.mod h1:' go.sum
    13
    14-- go.mod --
    15module example
    16
    17go 1.17
    18-- go.mod.want --
    19module example
    20
    21go 1.17
    22
    23require example.com/version v1.1.0 // indirect
    24-- main.go --
    25package main
    26
    27import (
    28	"fmt"
    29
    30	"example.com/version"
    31)
    32
    33func main() {
    34	fmt.Println(version.V)
    35}

View as plain text