diff --git a/binary/binary b/binary/binary new file mode 100755 index 0000000..843555d Binary files /dev/null and b/binary/binary differ diff --git a/bytewriter.go b/lib/bytewriter.go similarity index 97% rename from bytewriter.go rename to lib/bytewriter.go index 5c39e57..c9b602c 100644 --- a/bytewriter.go +++ b/lib/bytewriter.go @@ -2,7 +2,7 @@ // license. Its contents can be found at: // http://creativecommons.org/publicdomain/zero/1.0/ -package main +package bindata import ( "fmt" diff --git a/stringwriter.go b/lib/stringwriter.go similarity index 96% rename from stringwriter.go rename to lib/stringwriter.go index 40ffe93..278f35b 100644 --- a/stringwriter.go +++ b/lib/stringwriter.go @@ -2,7 +2,7 @@ // license. Its contents can be found at: // http://creativecommons.org/publicdomain/zero/1.0/ -package main +package bindata import ( "fmt" diff --git a/toc.go b/lib/toc.go similarity index 88% rename from toc.go rename to lib/toc.go index 54c73b7..b752678 100644 --- a/toc.go +++ b/lib/toc.go @@ -2,7 +2,7 @@ // license. Its contents can be found at: // http://creativecommons.org/publicdomain/zero/1.0/ -package main +package bindata import ( "fmt" @@ -13,7 +13,7 @@ import ( ) // createTOC writes a table of contents file to the given location. -func createTOC(dir, pkgname string) error { +func CreateTOC(dir, pkgname string) error { file := filepath.Join(dir, "bindata-toc.go") code := fmt.Sprintf(`package %s @@ -27,7 +27,7 @@ var go_bindata = make(map[string]func() []byte)`, pkgname) } // writeTOCInit writes the TOC init function for a given data file. -func writeTOCInit(output io.Writer, filename, prefix, funcname string) { +func WriteTOCInit(output io.Writer, filename, prefix, funcname string) { filename = strings.Replace(filename, prefix, "", 1) fmt.Fprintf(output, ` diff --git a/translate.go b/lib/translate.go similarity index 97% rename from translate.go rename to lib/translate.go index 6b1d973..a03160f 100644 --- a/translate.go +++ b/lib/translate.go @@ -2,7 +2,7 @@ // license. Its contents can be found at: // http://creativecommons.org/publicdomain/zero/1.0/ -package main +package bindata import ( "compress/gzip" @@ -11,7 +11,7 @@ import ( ) // translate translates the input file to go source code. -func translate(input io.Reader, output io.Writer, pkgname, funcname string, uncompressed, nomemcpy bool) { +func Translate(input io.Reader, output io.Writer, pkgname, funcname string, uncompressed, nomemcpy bool) { if nomemcpy { if uncompressed { translate_nomemcpy_uncomp(input, output, pkgname, funcname) diff --git a/version.go b/lib/version.go similarity index 97% rename from version.go rename to lib/version.go index 1fc2edd..38d44c2 100644 --- a/version.go +++ b/lib/version.go @@ -2,7 +2,7 @@ // license. Its contents can be found at: // http://creativecommons.org/publicdomain/zero/1.0/ -package main +package bindata import ( "fmt" diff --git a/main.go b/main.go index 718edd6..9dab45b 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ package main import ( "flag" "fmt" + "github.com/jteeuwen/go-bindata/lib" "os" "path" "path/filepath" @@ -34,7 +35,7 @@ func main() { parseArgs() if pipe { - translate(os.Stdin, os.Stdout, *pkgname, *funcname, *uncompressed, *nomemcopy) + bindata.Translate(os.Stdin, os.Stdout, *pkgname, *funcname, *uncompressed, *nomemcopy) return } @@ -59,20 +60,20 @@ func main() { } // Translate binary to Go code. - translate(fs, fd, *pkgname, *funcname, *uncompressed, *nomemcopy) + bindata.Translate(fs, fd, *pkgname, *funcname, *uncompressed, *nomemcopy) // Append the TOC init function to the end of the output file and // write the `bindata-toc.go` file, if applicable. if *toc { dir, _ := filepath.Split(*out) - err := createTOC(dir, *pkgname) + err := bindata.CreateTOC(dir, *pkgname) if err != nil { fmt.Fprintf(os.Stderr, "[e] %s\n", err) return } - writeTOCInit(fd, in, *prefix, *funcname) + bindata.WriteTOCInit(fd, in, *prefix, *funcname) } } @@ -85,7 +86,7 @@ func parseArgs() { flag.Parse() if *version { - fmt.Printf("%s\n", Version()) + fmt.Printf("%s\n", bindata.Version()) os.Exit(0) }