gotic

command module
v0.0.0-...-78cb33a Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2015 License: BSD-2-Clause Imports: 6 Imported by: 0

README

gotic

Converts files files into go code.

Concept

Gotic is both, a library and an utility. The library gotic/fswraps ioutil.ReadFile(). The utility, gotic, takes one or more files and genaraates go code representing them (as one or more []byte{ ... })

Install

As usual: go get github.com/gchaincl/gotic

Usage

Let's say you have a program (main.go) that reads af file:

package main

import "github.com/gchaincl/gotic/fs"

func main() {
  f, err := fs.ReadFile("some/file")
  if err != nil {
    panic(err)
  }
  
  println(string(f))
}

Now, to embed some/file into your code, just run:

$ gotic some/file > main_gotic.go

Generated main_gotic.go will look like:

package main

import "github.com/gchaincl/gotic/fs"

func init() {
	fs.Add("some/file", []byte{ "\xff\xd8\xff\xe1 ..." })
}

That's all, as gotic has Added some/file, each call to fs.ReadFile(), will return the embedded []byte instead of actually read the file.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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