Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / honnef.co / go / tools@v0.0.1-2020.1.5 / version / buildinfo.go
1 // +build go1.12
2
3 package version
4
5 import (
6         "fmt"
7         "runtime/debug"
8 )
9
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 {
16                         printModule(dep)
17                 }
18         } else {
19                 fmt.Println("Built without Go modules")
20         }
21 }
22
23 func buildInfoVersion() (string, bool) {
24         info, ok := debug.ReadBuildInfo()
25         if !ok {
26                 return "", false
27         }
28         if info.Main.Version == "(devel)" {
29                 return "", false
30         }
31         return info.Main.Version, true
32 }
33
34 func printModule(m *debug.Module) {
35         fmt.Printf("\t%s", m.Path)
36         if m.Version != "(devel)" {
37                 fmt.Printf("@%s", m.Version)
38         }
39         if m.Sum != "" {
40                 fmt.Printf(" (sum: %s)", m.Sum)
41         }
42         if m.Replace != nil {
43                 fmt.Printf(" (replace: %s)", m.Replace.Path)
44         }
45         fmt.Println()
46 }