1
0
mirror of https://github.com/golang/go synced 2024-11-23 06:00:08 -07:00

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

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/129650043
This commit is contained in:
ChaiShushan 2014-08-28 15:04:10 -07:00 committed by Rob Pike
parent b50dd6090d
commit dc11be8dda
3 changed files with 22 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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