Skip to content

flazz/togo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

togo – convert any file to .go source

Generates a Go source file with a []byte var containing the given file's contents.

Allows files to to be compiled (and linked) into a pkg. Quite handy for use with go generate.

Example:

Given some file foo.txt

% echo "hello world" >foo.txt

Convert it via togo

% togo -pkg bar -name foo -input ./foo.txt

A new file is created: foo.txt.go

% ls foo.txt*
foo.txt
foo.txt.go

With a var inside

% cat foo.txt.go
package bar

var foo = []byte{
	// 12 bytes from ./foo.txt
	0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x0a,
}

Releases

No releases published

Packages

No packages published