https://github.com/lucasepe/file2go
Convert any file to Go source.
https://github.com/lucasepe/file2go
command-line embed golang resources tool
Last synced: over 1 year ago
JSON representation
Convert any file to Go source.
- Host: GitHub
- URL: https://github.com/lucasepe/file2go
- Owner: lucasepe
- Created: 2024-05-31T15:40:09.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-31T15:49:39.000Z (about 2 years ago)
- Last Synced: 2025-03-09T14:36:38.239Z (over 1 year ago)
- Topics: command-line, embed, golang, resources, tool
- Language: Go
- Homepage: https://github.com/lucasepe/file2go
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# file2go
```txt
┌─┐┬ ┬ ┌─┐ ┌─┐┌─┐
├┤ │ │ ├┤ │ ┬│ │
└ ┴ ┴─┘└─┘ 2 └─┘└─┘
https://github.com/lucasepe/file2go
Convert any file to Go source.
SYNOPSIS:
file2go [string] [string]
DESCRIPTION:
The file2go utility reads a file from stdin and writes it to stdout,
converting each byte to its hex representation on the fly.
* if the first [string] is present, it is printed before the data
* if the second [string] is present, it is printed after the data
This program is used to embed binary or other files into Go source
files, for instance as a []byte.
EXAMPLES:
date | file2go 'var myDate = []byte {' '}'
will produce:
var myDate = []byte {
0x46, 0x72, 0x69, 0x20, 0x4d, 0x61, 0x79, 0x20, 0x33, 0x31,
0x20, 0x31, 0x37, 0x3a, 0x31, 0x38, 0x3a, 0x34, 0x38, 0x20,
0x43, 0x45, 0x53, 0x54, 0x20, 0x32, 0x30, 0x32, 0x34, 0x0a
}
```
---
I know very well about the go [package embed](https://pkg.go.dev/embed), but I wanted something _'old school'_.
If your workflow involves embedding multiple files, regenerating frequently your embedded data, then you definitely have to choose the [embed](https://pkg.go.dev/embed) package.