Commit dc11be8d authored by ChaiShushan's avatar ChaiShushan Committed by Rob Pike

crypto/md5: use go generate to create md5block.go

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/129650043
parent b50dd609
......@@ -7,7 +7,7 @@
// This program generates md5block.go
// Invoke as
//
// go run gen.go [-full] |gofmt >md5block.go
// go run gen.go [-full] -output md5block.go
//
// The -full flag causes the generated code to do a full
// (16x) unrolling instead of a 4x unrolling.
......@@ -15,18 +15,33 @@
package main
import (
"bytes"
"flag"
"go/format"
"io/ioutil"
"log"
"os"
"strings"
"text/template"
)
var filename = flag.String("output", "md5block.go", "output file name")
func main() {
flag.Parse()
var buf bytes.Buffer
t := template.Must(template.New("main").Funcs(funcs).Parse(program))
if err := t.Execute(os.Stdout, data); err != nil {
if err := t.Execute(&buf, data); err != nil {
log.Fatal(err)
}
data, err := format.Source(buf.Bytes())
if err != nil {
log.Fatal(err)
}
err = ioutil.WriteFile(*filename, data, 0644)
if err != nil {
log.Fatal(err)
}
}
......@@ -165,7 +180,7 @@ var program = `// Copyright 2013 The Go Authors. All rights reserved.
// license that can be found in the LICENSE file.
// DO NOT EDIT.
// Generate with: go run gen.go{{if .Full}} -full{{end}} | gofmt >md5block.go
// Generate with: go run gen.go{{if .Full}} -full{{end}} -output md5block.go
package md5
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:generate go run gen.go -full -output md5block.go
// Package md5 implements the MD5 hash algorithm as defined in RFC 1321.
package md5
......
......@@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.
// DO NOT EDIT.
// Generate with: go run gen.go -full | gofmt >md5block.go
// Generate with: go run gen.go -full -output md5block.go
package md5
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment