Documentation ¶
Overview ¶
Command binpack is a Go generator for packing static assets into Go packages.
Deprecated: Go 1.16 has native support for embedded files
For example, if you have a file base.html in your package containing:
<html><body>{{.body}}</body></html>
You can add a generate line anywhere in your package:
//go:generate binpack -name myTemplate base.html
Then running go generate will produce a myTemplate_packed.go containing:
// Code generated by "binpack -name myTemplate base.html"; DO NOT EDIT. package foo const myTemplate = "<html><body>{{.body}}</body></html>"
This also works for binary files, although the generated source is very inefficient as it is encoded as a string literal (but after compiling the data should not take up any extra space).
Click to show internal directories.
Click to hide internal directories.