All Projects → akavel → embd-go

akavel / embd-go

Licence: other
embd-go is an embeddable command-line tool for embedding data files in Go source code, specially crafted for easy use with `go generate`.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to embd-go

Ris
a simple cross-platform resource compiler for c++ projects
Stars: ✭ 15 (-37.5%)
Mutual labels:  binary, resources, embed
awesome-solidity-gas-optimization
Best resources for Solidity gas optimizations ⛽
Stars: ✭ 893 (+3620.83%)
Mutual labels:  resources
affiliate
Add affiliation tags to links automatically in the browser
Stars: ✭ 77 (+220.83%)
Mutual labels:  link
react-use-downloader
Creates a download handler function and gives progress information
Stars: ✭ 65 (+170.83%)
Mutual labels:  link
fastproto
FastProto is a binary data processing tool written in Java.
Stars: ✭ 65 (+170.83%)
Mutual labels:  binary
surge
Simple, specialised, and efficient binary marshaling
Stars: ✭ 36 (+50%)
Mutual labels:  binary
loopback-ds-paginate-mixin
A mixin to provide pagination for loopback Model properties
Stars: ✭ 31 (+29.17%)
Mutual labels:  mit
Cheatsheets
Quick reference material for techies
Stars: ✭ 66 (+175%)
Mutual labels:  resources
NALib
General purpose C sourcecode collection
Stars: ✭ 16 (-33.33%)
Mutual labels:  binary
health-check
Health Check is an application that provides an API to check the health health_check of some parts and some utilities like ping requests. This application can works as standalone or included in a Django project.
Stars: ✭ 31 (+29.17%)
Mutual labels:  resources
binstruct
Golang binary decoder for mapping data into the structure
Stars: ✭ 67 (+179.17%)
Mutual labels:  binary
purescript-resources
This is a repository for a docs site on how to figure things out in PureScript as recommended by me.
Stars: ✭ 47 (+95.83%)
Mutual labels:  resources
link-verifier
A tool for verifying links in text-based files
Stars: ✭ 26 (+8.33%)
Mutual labels:  link
awesome-calculus
🍹 A list of awesome resources I used to study Calculus.
Stars: ✭ 47 (+95.83%)
Mutual labels:  resources
awesome-coder-resources
编程路上加油站!------【持续更新中...欢迎star,欢迎常回来看看......】【内容:编程/学习/阅读资源,开源项目,面试题,网站,书,博客,教程等等】
Stars: ✭ 54 (+125%)
Mutual labels:  resources
kube-green
A K8s operator to reduce CO2 footprint of your clusters
Stars: ✭ 418 (+1641.67%)
Mutual labels:  resources
resources
A curated collection of useful tech resources 💻
Stars: ✭ 57 (+137.5%)
Mutual labels:  resources
awesome-software-dev
🔥 💯 📖 Curated list of documentation, plugins, links and more for software developers 📖
Stars: ✭ 23 (-4.17%)
Mutual labels:  resources
literate-binary
Integrate handcrafted binary and documentation
Stars: ✭ 37 (+54.17%)
Mutual labels:  binary
simpledb
No description or website provided.
Stars: ✭ 50 (+108.33%)
Mutual labels:  mit

About embd-go tool

License: MIT.

embd-go is an embeddable command-line tool for embedding data files in Go source code, specially crafted for easy use with go generate.

Easy use with go generate

The embd.go is a single, self-contained, MIT-licensed, go-runnable file, so you can copy it verbatim into your own project's repository, and keep it there forever:

         go get -d -u github.com/akavel/embd-go
Windows: copy %GOPATH%\src\github.com\akavel\embd-go\embd.go tools\embd.go
Linux:   cp $GOPATH/src/github.com/akavel/embd-go/embd.go tools/embd.go

and then call from e.g. go generate via go run, by putting a line like shown below in one of your Go source files:

//go:generate go run tools/embd.go -o embd/data.go -p embd MY_DATA/HELLO.DAT MY_DIRECTORY

Usage

USAGE: go run embd.go [FLAGS] PATH...
  -o="embd/data.go": Path to generated file.
  -p="embd": Package that the generated file should be in.

Note: directories that are used as a PATH will be added non-recursively (only immediate children)

Example

C:> go get github.com/akavel/embd-go
C:> echo Hello> hello.txt
C:> embd-go.exe -o hello.go -p main hello.txt
C:> type hello.go
// DO NOT EDIT BY HAND
//
// Generated with:
//
//      embd-go "-o" "hello.go" "-p" "main" "hello.txt"

package main

// File_hello_txt contains contents of "hello.txt" file.
var File_hello_txt = []byte("Hello\r\n")

Also, you could use directories as PATH. For example:

$ mkdir -p configs
$ echo 'config1' > configs/1.conf
$ echo 'config2' > configs/2.conf
$ ./embd-go -p "configs" configs
$ cat embd/data.go
// DO NOT EDIT BY HAND
//
// Generated with:
//
//	embd-go "-p" "configs" "configs"

package configs

var Dir_configs = struct {
	// File_1_conf contains contents of "configs/1.conf" file.
	File_1_conf []byte
	// File_2_conf contains contents of "configs/2.conf" file.
	File_2_conf []byte
}{
	[]byte("config1\n"),
	[]byte("config2\n"),
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].