10 func printBuildInfo() {
11 if info, ok := debug.ReadBuildInfo(); ok {
12 fmt.Println("Main module:")
13 printModule(&info.Main)
14 fmt.Println("Dependencies:")
15 for _, dep := range info.Deps {
19 fmt.Println("Built without Go modules")
23 func buildInfoVersion() (string, bool) {
24 info, ok := debug.ReadBuildInfo()
28 if info.Main.Version == "(devel)" {
31 return info.Main.Version, true
34 func printModule(m *debug.Module) {
35 fmt.Printf("\t%s", m.Path)
36 if m.Version != "(devel)" {
37 fmt.Printf("@%s", m.Version)
40 fmt.Printf(" (sum: %s)", m.Sum)
43 fmt.Printf(" (replace: %s)", m.Replace.Path)