Skip to content

Embedder is a function/command to embed resources in Go source files

License

Notifications You must be signed in to change notification settings

pierods/embedder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

embedder

License Go Report Card Build Status

Embedder is a function/command line utility to embed a binary or non-binary resource into a Go package.

Usage

As a library:

    hW := []byte("hello, world")
    
    embedded, err := Embed("AssetVar", hW)
    if err != nil {
        t.Fatal(err)
    }
    embedded = append([]byte("package mypackage \n"), embedded...)
    if err != nil {
        ...
    }
    ioutil.WriteFile("MyEmbeddedAsset.go", embedded, os.ModePerm)
    ...

	

As a command-line utility:

    embed -package mypackage -var MyImageGif -asset myImage.gif > MyEmbeddedAsset.go

In go:generate:

//go:generate  embed -package mypackage -var MyImageGif -asset myImage.gif -o MyEmbeddedAsset.go 

Installation:

    go get github.com/pierods/embedder
    cd %GOPATH/src/github.com/pierods/embedder/embed
    go install

Why not go-binddata, statik etc

go-bindata: 47 issues, compiles with Makefile

statik: it creates a statikFS fileserver - I don't need a fileserver

rice: it crates an HTTPBox - I don't need a box.

etc.

Embedder does one thing and does it well - embedding resources. You can then wrap the embedded resource in a file server or whatever.

About

Embedder is a function/command to embed resources in Go source files

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages