Text file src/cmd/go/testdata/mod/example.com_printversion_v0.1.0.txt

     1  example.com/printversion v0.1.0
     2  
     3  -- .mod --
     4  module example.com/printversion
     5  -- .info --
     6  {"Version":"v0.1.0"}
     7  -- README.txt --
     8  There is no go.mod file for this version of the module.
     9  -- printversion.go --
    10  package main
    11  
    12  import (
    13  	"fmt"
    14  	"os"
    15  	"runtime/debug"
    16  
    17  	_ "example.com/version"
    18  )
    19  
    20  func main() {
    21  	info, _ := debug.ReadBuildInfo()
    22  	fmt.Fprintf(os.Stdout, "path is %s\n", info.Path)
    23  	fmt.Fprintf(os.Stdout, "main is %s %s\n", info.Main.Path, info.Main.Version)
    24  	if r := info.Main.Replace; r != nil {
    25  		fmt.Fprintf(os.Stdout, "\t(replaced by %s %s)\n", r.Path, r.Version)
    26  	}
    27  	for _, m := range info.Deps {
    28  		fmt.Fprintf(os.Stdout, "using %s %s\n", m.Path, m.Version)
    29  		if r := m.Replace; r != nil {
    30  			fmt.Fprintf(os.Stdout, "\t(replaced by %s %s)\n", r.Path, r.Version)
    31  		}
    32  	}
    33  }
    34  

View as plain text