...

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

Documentation: cmd/go/testdata/mod

     1example.com/printversion v1.0.0
     2
     3-- .mod --
     4module example.com/printversion
     5
     6require example.com/version v1.0.0
     7replace example.com/version v1.0.0 => ../oops v0.0.0
     8exclude example.com/version v1.1.0
     9-- .info --
    10{"Version":"v1.0.0"}
    11-- go.mod --
    12module example.com/printversion
    13
    14require example.com/version v1.0.0
    15replace example.com/version v1.0.0 => ../oops v0.0.0
    16exclude example.com/version v1.0.1
    17-- printversion.go --
    18package main
    19
    20import (
    21	"fmt"
    22	"os"
    23	"runtime/debug"
    24
    25	_ "example.com/version"
    26)
    27
    28func 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}

View as plain text