Skip to content

Commit dca80ee

Browse files
committed
update
1 parent 4fe82bc commit dca80ee

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"path/filepath"
99
"sort"
10+
"strings"
1011

1112
"github.com/webx-top/com"
1213
"golang.org/x/mod/modfile"
@@ -32,7 +33,11 @@ func main() {
3233
pkgDir := filepath.Dir(modfilePath)
3334
vendorDir := filepath.Join(pkgDir, `vendor`)
3435
results := Files{}
36+
var maxLen int
3537
for _, req := range f.Require {
38+
if len(req.Mod.Path) > maxLen {
39+
maxLen = len(req.Mod.Path)
40+
}
3641
dir := filepath.Join(vendorDir, req.Mod.Path)
3742
fi, err := os.Stat(dir)
3843
if err != nil {
@@ -53,8 +58,9 @@ func main() {
5358
results = append(results, &File{Path: req.Mod.Path, Size: size})
5459
}
5560
sort.Sort(results)
61+
maxLen++
5662
for _, file := range results {
57-
fmt.Println(file.Path + "\t\t\t" + com.HumaneFileSize(uint64(file.Size)))
63+
fmt.Println(file.Path, strings.Repeat(` `, maxLen-len(file.Path)), com.HumaneFileSize(uint64(file.Size)))
5864
}
5965
}
6066

0 commit comments

Comments
 (0)