Text file src/cmd/go/testdata/mod/example.com_printversion_v1.0.0.txt

     1  example.com/printversion v1.0.0
     2  
     3  -- .mod --
     4  module example.com/printversion
     5  
     6  require example.com/version v1.0.0
     7  replace example.com/version v1.0.0 => ../oops v0.0.0
     8  exclude example.com/version v1.1.0
     9  -- .info --
    10  {"Version":"v1.0.0"}
    11  -- go.mod --
    12  module example.com/printversion
    13  
    14  require example.com/version v1.0.0
    15  replace example.com/version v1.0.0 => ../oops v0.0.0
    16  exclude example.com/version v1.0.1
    17  -- printversion.go --
    18  package main
    19  
    20  import (
    21  	"fmt"
    22  	"os"
    23  	"runtime/debug"
    24  
    25  	_ "example.com/version"
    26  )
    27  
    28  func main() {
    29  	info, _ := debug.ReadBuildInfo()
    30  	fmt.Fprintf(os.Stdout, "path is %s\n", info.Path)
    31  	fmt.Fprintf(os.Stdout, "main is %s %s\n", info.Main.Path, info.Main.Version)
    32  	if r := info.Main.Replace; r != nil {
    33  		fmt.Fprintf(os.Stdout, "\t(replaced by %s %s)\n", r.Path, r.Version)
    34  	}
    35  	for _, m := range info.Deps {
    36  		fmt.Fprintf(os.Stdout, "using %s %s\n", m.Path, m.Version)
    37  		if r := m.Replace; r != nil {
    38  			fmt.Fprintf(os.Stdout, "\t(replaced by %s %s)\n", r.Path, r.Version)
    39  		}
    40  	}
    41  }
    42  

View as plain text