binpack

command module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

binpack

Deprecated: Go 1.16 has native support for embedded files.

Command binpack is a Go generator for packing static assets into Go packages.

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).

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL