bindata/toc.go
Jim Teeuwen cca9f8e6b7 Removes output of both debug and release code. There really
is no point to this.

All output (including TOC) is now written to a single output file.
This allows us to have different output file names to be specified.
Each for a different version generated code with its own build tags.
Consequently offering much greater flexibility in the way generated
code is to be used in a host application.

Fixes test outputs to match all these changes.
2013-10-30 14:45:04 +01:00

60 lines
1.3 KiB
Go

// 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/
package bindata
import (
"fmt"
"io"
)
// writeTOC writes the table of contents file.
func writeTOC(w io.Writer, toc []Asset) error {
err := writeTOCHeader(w)
if err != nil {
return err
}
for i := range toc {
err = writeTOCAsset(w, &toc[i])
if err != nil {
return err
}
}
return writeTOCFooter(w)
}
// writeTOCHeader writes the table of contents file header.
func writeTOCHeader(w io.Writer) error {
_, err := fmt.Fprintf(w, `
// Asset loads and returns the asset for the given name.
// This returns nil of the asset could not be found.
func Asset(name string) []byte {
if f, ok := _bindata[name]; ok {
return f()
}
return nil
}
// _bindata is a table, holding each asset generator, mapped to its name.
var _bindata = map[string] func() []byte {
`)
return err
}
// writeTOCAsset write a TOC entry for the given asset.
func writeTOCAsset(w io.Writer, asset *Asset) error {
_, err := fmt.Fprintf(w, "\t%q: %s,\n", asset.Name, asset.Func)
return err
}
// writeTOCFooter writes the table of contents file footer.
func writeTOCFooter(w io.Writer) error {
_, err := fmt.Fprintf(w, `
}
`)
return err
}