Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.
/ gotic Public archive

Converts files into go code. Useful for embedding resources into your binaries

License

Notifications You must be signed in to change notification settings

qustavo/gotic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Converts files into go code. Useful for embedding resources into your binaries

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages