https://github.com/flazz/togo
convert any file to Go source
https://github.com/flazz/togo
byte file generator golang tool
Last synced: about 1 year ago
JSON representation
convert any file to Go source
- Host: GitHub
- URL: https://github.com/flazz/togo
- Owner: flazz
- Created: 2017-03-20T14:33:13.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-20T14:55:12.000Z (over 9 years ago)
- Last Synced: 2025-05-07T11:39:43.824Z (about 1 year ago)
- Topics: byte, file, generator, golang, tool
- Language: Go
- Size: 54.7 KB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](https://blog.golang.org/generate).
## Example:
Given some file `foo.txt`
```{.sh}
% echo "hello world" >foo.txt
```
Convert it via *togo*
```{.sh}
% togo -pkg bar -name foo -input ./foo.txt
```
A new file is created: `foo.txt.go`
```{.sh}
% ls foo.txt*
foo.txt
foo.txt.go
```
With a var inside
```{.sh}
% 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,
}
```