Tool to pack files with binary in GoLang

A GO packager tool to pack templates/static files with the binary and extract it at the runtime.

GoPkgr is a tool which is used to pack static files, small images, text files, etc along with the binary. Since GoLang binary do not include static files along with them, this tool comes in handy while creating a CLI tool or creating a tool which requires HTML type files for the tool to work. Sometimes we also have to include keys, certs, etc, GoPkgr can pack all these files in structured format and extract them at the run time wherever you want. You can also delete those files after the tool exits i.e. use those files as temp files.

gopkgr in action

Import this as a module and build with your project or compile from source. You can also download the binary and use them. Binary available for both platforms, linux and windows.

For windows(v1.4.7):

For linux(v1.4.7):

To use this tool, just put the compiled binary or run the GO program in the same directory, for example, if you want to pack temp folder ,then, put binary inside temp folder and execute it. It will automatically read directory and file structure and pack them in a formatted structure. When you unpack these files, these files and folders will be unpacked in the same structure. It can read sub folders and files inside sub folders, so you need not to worry about how deep the file is inside folders.
After execution this tool will create a pkg.go file. Keep this file with in your project while compiling. By default, the package will be main but you can change the package name according to your project needs in the pkg.go file.

To unpack, just call unpkr(dir) method like,

err := unpkr(dir)

unpkr method return an error if some error exists else it will return nil.
dir is the name of the directory where the package will be unpacked.
Use “.” to unpack in the same directory.
To remove these files after the program exits, one can make use of
method else the unpacked files will remain.

For more information, issue, query or contact go to the github repo and read

Thanks for reading!!

Cyber Security Researcher