2goarray

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2015 License: MIT Imports: 5 Imported by: 0

README

2goarray

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/cratonica/2goarray

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/2gorray MyArray mypackage < 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,
}

Documentation

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL