assets

package module
v0.0.0-...-24bf07c Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2014 License: MIT Imports: 2 Imported by: 0

README

Assets

Magically bundle (some) assets into your Golang binaries.

Uses a combination of boring function calls and a (horrible genius) pre-processor to generate a magical binary with pre-bundled assets.

When does it work? When you use the very small and limited setup that this was tested in and designed for. When does it NOT work? When you don't live on Planet Sysrq.

Definitely don't use this when you're working with very large files - really, you shouldn't want to embed those in the first place. This means trying to embed a copy of the world's greatest film (Hackers (1995)) in your app is probably not a good idea the greatest example ever made. (see: example/)

The gist is this:

  1. go get github.com/sysr-q/assets
  2. go install github.com/sysr-q/assets/goappc
  3. import "github.com/sysr-q/assets"
  4. foo := string(assets.MustRead("templates/blah.html")) (for example)
  5. goappc . (runs magical preprocessor, bundles assets, runs go build)
  6. Deploy!

NOTE! goappc is still not complete - currently it will only process a single file. Not really what you want, right? I'll remedy this sometime soon.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustRead

func MustRead(file string) []byte

MustRead is identical to Read, however if an error is returned, MustRead will panic.

func Read

func Read(file string) ([]byte, error)

Read is a superficial wrapper on top of io/ioutil.ReadAll, which simply calls os.Open(file) first. It exists mainly to be rewritten by the magic Assets preprocessor.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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