2013-07-25 20:46:12 +00:00
|
|
|
// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
|
|
|
|
// license. Its contents can be found at:
|
|
|
|
// http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
|
2013-09-30 18:46:15 +00:00
|
|
|
package bindata
|
2013-07-25 20:46:12 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io/ioutil"
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
// createTOC writes a table of contents file to the given location.
|
2013-09-30 18:46:15 +00:00
|
|
|
func CreateTOC(dir, pkgname string) error {
|
2013-08-01 10:10:59 +00:00
|
|
|
file := filepath.Join(dir, "bindata-toc.go")
|
2013-07-25 20:46:12 +00:00
|
|
|
code := fmt.Sprintf(`package %s
|
|
|
|
|
|
|
|
// Global Table of Contents map. Generated by go-bindata.
|
|
|
|
// After startup of the program, all generated data files will
|
|
|
|
// put themselves in this map. The key is the full filename, as
|
|
|
|
// supplied to go-bindata.
|
2013-08-01 10:10:59 +00:00
|
|
|
var go_bindata = make(map[string]func() []byte)`, pkgname)
|
2013-07-25 20:46:12 +00:00
|
|
|
|
|
|
|
return ioutil.WriteFile(file, []byte(code), 0600)
|
|
|
|
}
|
|
|
|
|
|
|
|
// writeTOCInit writes the TOC init function for a given data file.
|
2013-09-30 18:46:15 +00:00
|
|
|
func WriteTOCInit(output io.Writer, filename, prefix, funcname string) {
|
2013-07-25 20:46:12 +00:00
|
|
|
filename = strings.Replace(filename, prefix, "", 1)
|
|
|
|
fmt.Fprintf(output, `
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
go_bindata[%q] = %s
|
|
|
|
}
|
|
|
|
`, filename, funcname)
|
|
|
|
}
|