go-examples/my-fnv/main.go

24 lines
313 B
Go
Raw Normal View History

2017-07-08 08:29:47 +00:00
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())
}