1 // Copyright 2014 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.
7 //go:generate go run makestatic.go
19 "analysis/call-eg.png",
20 "analysis/callers1.png",
21 "analysis/callers2.png",
23 "analysis/chan2a.png",
24 "analysis/chan2b.png",
25 "analysis/error1.png",
27 "analysis/ident-def.png",
28 "analysis/ident-field.png",
29 "analysis/ident-func.png",
30 "analysis/ipcg-func.png",
31 "analysis/ipcg-pkg.png",
32 "analysis/typeinfo-pkg.png",
33 "analysis/typeinfo-src.png",
42 "images/treeview-black-line.gif",
43 "images/treeview-black.gif",
44 "images/treeview-default-line.gif",
45 "images/treeview-default.gif",
46 "images/treeview-gray-line.gif",
47 "images/treeview-gray.gif",
50 "jquery.treeview.css",
51 "jquery.treeview.edit.js",
65 // Generate reads a set of files and returns a file buffer that declares
66 // a map of string constants containing contents of the input files.
67 func Generate() ([]byte, error) {
68 buf := new(bytes.Buffer)
69 fmt.Fprintf(buf, "%v\n\n%v\n\npackage static\n\n", license, warning)
70 fmt.Fprintf(buf, "var Files = map[string]string{\n")
71 for _, fn := range files {
72 b, err := ioutil.ReadFile(fn)
76 fmt.Fprintf(buf, "\t%q: ", fn)
78 fmt.Fprintf(buf, ",\n\n")
80 fmt.Fprintln(buf, "}")
81 return format.Source(buf.Bytes())
84 // appendQuote is like strconv.AppendQuote, but we avoid the latter
85 // because it changes when Unicode evolves, breaking gen_test.go.
86 func appendQuote(out *bytes.Buffer, data []byte) {
88 for _, b := range data {
89 if b == '\\' || b == '"' {
92 } else if b <= unicode.MaxASCII && unicode.IsPrint(rune(b)) && !unicode.IsSpace(rune(b)) {
95 fmt.Fprintf(out, "\\x%02x", b)
101 const warning = `// Code generated by "makestatic"; DO NOT EDIT.`
103 const license = `// Copyright 2013 The Go Authors. All rights reserved.
104 // Use of this source code is governed by a BSD-style
105 // license that can be found in the LICENSE file.`