...

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

Documentation: cmd/go/testdata/mod

     1example.com/printversion v0.1.0
     2
     3-- .mod --
     4module example.com/printversion
     5-- .info --
     6{"Version":"v0.1.0"}
     7-- README.txt --
     8There is no go.mod file for this version of the module.
     9-- printversion.go --
    10package main
    11
    12import (
    13	"fmt"
    14	"os"
    15	"runtime/debug"
    16
    17	_ "example.com/version"
    18)
    19
    20func 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}

View as plain text