From d4437bf59744b83da8bb401f87f0ae099fc66564 Mon Sep 17 00:00:00 2001 From: Konstantin Shaposhnikov Date: Thu, 28 Apr 2016 10:55:11 +0800 Subject: [PATCH] imports: add go:generate directive for generating zstdlib.go Change-Id: I8c54e01799f690819cda746ad5fb7c4d87e769c4 Reviewed-on: https://go-review.googlesource.com/22541 Reviewed-by: Brad Fitzpatrick --- imports/imports.go | 2 ++ imports/mkstdlib.go | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/imports/imports.go b/imports/imports.go index 9260823ce6..c26c1946a6 100644 --- a/imports/imports.go +++ b/imports/imports.go @@ -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 mkstdlib.go + // Package imports implements a Go pretty-printer (like package "go/format") // that also adds or removes import statements as necessary. package imports // import "golang.org/x/tools/imports" diff --git a/imports/mkstdlib.go b/imports/mkstdlib.go index f72d2442db..3a2e39d7a3 100644 --- a/imports/mkstdlib.go +++ b/imports/mkstdlib.go @@ -11,6 +11,7 @@ import ( "fmt" "go/format" "io" + "io/ioutil" "log" "os" "path" @@ -90,5 +91,8 @@ func main() { if err != nil { log.Fatal(err) } - os.Stdout.Write(fmtbuf) + err = ioutil.WriteFile("zstdlib.go", fmtbuf, 0666) + if err != nil { + log.Fatal(err) + } }