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