diff options
Diffstat (limited to 'recipes-devtools/go-dirhash-native/go-dirhash/dirhash-helper.go')
| -rw-r--r-- | recipes-devtools/go-dirhash-native/go-dirhash/dirhash-helper.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/recipes-devtools/go-dirhash-native/go-dirhash/dirhash-helper.go b/recipes-devtools/go-dirhash-native/go-dirhash/dirhash-helper.go new file mode 100644 index 00000000..d2aec41c --- /dev/null +++ b/recipes-devtools/go-dirhash-native/go-dirhash/dirhash-helper.go | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | package main | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "fmt" | ||
| 5 | "os" | ||
| 6 | |||
| 7 | "golang.org/x/mod/sumdb/dirhash" | ||
| 8 | ) | ||
| 9 | |||
| 10 | func main() { | ||
| 11 | if len(os.Args) != 2 { | ||
| 12 | fmt.Fprintf(os.Stderr, "Usage: %s <zip-file>\n", os.Args[0]) | ||
| 13 | os.Exit(1) | ||
| 14 | } | ||
| 15 | |||
| 16 | zipPath := os.Args[1] | ||
| 17 | hash, err := dirhash.HashZip(zipPath, dirhash.DefaultHash) | ||
| 18 | if err != nil { | ||
| 19 | fmt.Fprintf(os.Stderr, "Error: %v\n", err) | ||
| 20 | os.Exit(1) | ||
| 21 | } | ||
| 22 | |||
| 23 | fmt.Println(hash) | ||
| 24 | } | ||
