Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flazz/togo
convert any file to Go source
https://github.com/flazz/togo
byte file generator golang tool
Last synced: 6 days 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 7 years ago)
- Default Branch: master
- Last Pushed: 2017-03-20T14:55:12.000Z (over 7 years ago)
- Last Synced: 2024-06-21T04:48:21.924Z (5 months ago)
- Topics: byte, file, generator, golang, tool
- Language: Go
- Size: 54.7 KB
- Stars: 12
- Watchers: 3
- 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 barvar foo = []byte{
// 12 bytes from ./foo.txt
0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x0a,
}
```