2014-11-04 22:52:40 -07:00
|
|
|
// Copyright 2013 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// +build ignore
|
|
|
|
|
2018-04-28 13:20:38 -06:00
|
|
|
// Command makestatic writes the generated file buffer to "static.go".
|
2015-02-27 20:16:22 -07:00
|
|
|
// It is intended to be invoked via "go generate" (directive in "gen.go").
|
2014-11-04 22:52:40 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
|
2018-04-28 13:20:38 -06:00
|
|
|
"golang.org/x/tools/godoc/static"
|
|
|
|
)
|
2014-11-04 22:52:40 -07:00
|
|
|
|
|
|
|
func main() {
|
2015-02-27 20:16:22 -07:00
|
|
|
if err := makestatic(); err != nil {
|
2014-11-04 22:52:40 -07:00
|
|
|
fmt.Fprintln(os.Stderr, err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-27 20:16:22 -07:00
|
|
|
func makestatic() error {
|
2018-04-28 13:20:38 -06:00
|
|
|
buf, err := static.Generate()
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("error while generating static.go: %v\n", err)
|
2014-11-04 22:52:40 -07:00
|
|
|
}
|
2018-04-28 13:20:38 -06:00
|
|
|
err = ioutil.WriteFile("static.go", buf, 0666)
|
2016-05-27 20:59:14 -06:00
|
|
|
if err != nil {
|
2018-04-28 13:20:38 -06:00
|
|
|
return fmt.Errorf("error while writing static.go: %v\n", err)
|
2014-11-04 22:52:40 -07:00
|
|
|
}
|
2018-04-28 13:20:38 -06:00
|
|
|
return nil
|
2014-11-04 22:52:40 -07:00
|
|
|
}
|