forked from kevwan/depu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
54 lines (45 loc) · 883 Bytes
/
Copy pathmain.go
File metadata and controls
54 lines (45 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"fmt"
"os"
"github.com/olekukonko/tablewriter"
)
func main() {
directs, err := getDirectModules()
if err != nil {
fmt.Fprintf(os.Stderr, "parseGoMod: %v\n", err)
return
}
modules, err := getDepPackages()
if err != nil {
fmt.Fprintf(os.Stderr, "parseModules: %v\n", err)
return
}
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Package", "Current", "Latest", "GoVersion"})
table.SetBorder(false)
for _, mod := range modules {
if mod.Update == nil {
continue
}
if !contains(directs, mod.Path) {
continue
}
table.Append([]string{
mod.Path,
mod.Version,
mod.Update.Version,
mod.GoVersion,
})
}
table.Render()
}
// contains checks if str is in list.
func contains(list []string, str string) bool {
for _, each := range list {
if each == str {
return true
}
}
return false
}