Skip to content

A simple utility to encode a file (or any other data) into a Go byte array.

License

Notifications You must be signed in to change notification settings

javafx-dev/2gobytes

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2gobytes Build Status

A simple utility to encode a file (or any other data) into a Go byte slice.

Having set up your Go environment, simply run

go get github.com/paulvollmer/2gobytes

Then use by piping a file into the utility and capturing the output. You must provide a name for the generated slice symbol and package name. For example:

$GOPATH/bin/2gobytes -p mypackage -a MyArray < myimage.png > myimage.go

This will output something like:

package mypackage

var MyArray []byte = []byte {
  0x49, 0x20, 0x63, 0x61, 0x6e, 0x27, 0x74, 0x20, 0x62, 0x65, 0x6c, 0x69,
  0x65, 0x76, 0x65, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x61, 0x63, 0x74, 0x75,
  0x61, 0x6c, 0x6c, 0x79, 0x20, 0x64, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x64,
  0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x20, 0x4b, 0x75, 0x64, 0x6f, 0x73,
  0x20, 0x66, 0x6f, 0x72, 0x20, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x20, 0x74,
  0x68, 0x6f, 0x72, 0x6f, 0x75, 0x67, 0x68, 0x2e, 0x0a,
}

Contributors

About

A simple utility to encode a file (or any other data) into a Go byte array.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 96.0%
  • Makefile 4.0%