Code Monkey home page Code Monkey logo

embed's Introduction

embed

⚠️ DEPRECATED ⚠️

Please use embed from Go's standard library instead.


CI

embed is a tool for embedding static content in your Go application.

It provides three methods, listing embedded files and getting their content as []byte or string. If you need a io.Writer just wrap the []byte content in a bytes.NewBuffer.

The motivation for building yet another static file embedding tool for Go was that I am not satisfied with any of the existing tools, they either have inconvenient APIs or did not support to include more than a single folder or file.

Please note that this tool, as well as most other static file embedding tools, will be redundant as soon as the proposal to add support for embedded files lands in go/cmd.

Usage

a demo of embed

You can run the tool with go run github.com/klingtnet/embed/cmd/embed or by downloading a precompiled binary from the releases page.

$ ./embed
NAME:
   embed - A new cli application

USAGE:
   embed [global options] command [command options] [arguments...]

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --package value, -p value                    name of the package the generated Go file is associated to (default: "main")
   --destination value, --dest value, -d value  where to store the generated Go file (default: "embeds.go")
   --include value, -i value                    paths to embed, directories are stored recursively (can be used multiple times)
   --help, -h                                   show help (default: false)

Running embed --include assets --include views will create a file embeds.go (you can change the destination) that bundles all files from the assets and views directory. In your application you can then use embeds.File("assets/my-asset.png") to get the contents of an embedded file. For an example of such a generated file see internal/embeds.go.

golang-migrate driver

The package also provides a migration source driver for golang-migrate. For a usage example refer to examples/migrate/migrate.go.

embed's People

Contributors

agebhar1 avatar klingtnet avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.