go-examples/my-fnv/main.go
2017-07-08 10:29:47 +02:00

24 lines
313 B
Go

package main
import "fmt"
import "hash/fnv"
import "io"
import "log"
import "os"
func main() {
if len(os.Args) < 2 {
log.Fatalln("Usage my-fmv file")
}
f, err := os.Open(os.Args[1])
if err != nil {
log.Fatalln(err)
}
defer f.Close()
h := fnv.New64()
io.Copy(h, f)
fmt.Printf("%x\n", h.Sum64())
}