gofmt and add option to print file name
This commit is contained in:
parent
170b23f5ec
commit
dc5d58bf87
11
main.go
11
main.go
@ -2,21 +2,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"flag"
|
||||
"fmt"
|
||||
"hash"
|
||||
"hash/crc32"
|
||||
"hash/crc64"
|
||||
"encoding/binary"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
mode := flag.String("mode", "crc32",
|
||||
"CRC method to use. Valid values are 'crc32' (IEEE), 'crc64-iso', and 'crc64-ecma'")
|
||||
mode := flag.String("mode", "crc32", "CRC method to use. Valid values are 'crc32' (IEEE), 'crc64-iso', and 'crc64-ecma'")
|
||||
printName := flag.Bool("p", false, "Print the file name along with the checksum")
|
||||
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintf(os.Stderr, "Usage: %s [-mode=<MODE>] file [file ...]\n", os.Args[0])
|
||||
fmt.Fprintf(os.Stderr, "Usage: %s [-mode=<MODE>] [-p] file [file ...]\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
flag.Parse()
|
||||
@ -49,7 +50,7 @@ func main() {
|
||||
continue
|
||||
}
|
||||
|
||||
if flag.NArg() == 1 {
|
||||
if flag.NArg() == 1 && !*printName {
|
||||
fmt.Printf("%0*d\n", hasher.Size(), binary.BigEndian.Uint32(hasher.Sum(nil)))
|
||||
} else {
|
||||
fmt.Printf("%0*d\t%s\n", hasher.Size(), binary.BigEndian.Uint32(hasher.Sum(nil)), filename)
|
||||
|
Loading…
Reference in New Issue
Block a user