github.com/jd-ly/tools@v0.5.7/godoc/static/makestatic.go (about) 1 // Copyright 2013 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build ignore 6 7 // Command makestatic writes the generated file buffer to "static.go". 8 // It is intended to be invoked via "go generate" (directive in "gen.go"). 9 package main 10 11 import ( 12 "fmt" 13 "io/ioutil" 14 "os" 15 16 "github.com/jd-ly/tools/godoc/static" 17 ) 18 19 func main() { 20 if err := makestatic(); err != nil { 21 fmt.Fprintln(os.Stderr, err) 22 os.Exit(1) 23 } 24 } 25 26 func makestatic() error { 27 buf, err := static.Generate() 28 if err != nil { 29 return fmt.Errorf("error while generating static.go: %v\n", err) 30 } 31 err = ioutil.WriteFile("static.go", buf, 0666) 32 if err != nil { 33 return fmt.Errorf("error while writing static.go: %v\n", err) 34 } 35 return nil 36 }