nrsc: Index | Files | Directories

package nrsc

import ""

Serving resource from zip file appended to Go executable (this enables on file deploy).

Making it happen:

1. Add code to serve resources (see example below)
2. Compile your executable
3. Run "nrsc /path/to/exe /path/to/resources"
4. Deploy

Example code:

package main

import (


type params struct {
	Number  int

func indexHandler(w http.ResponseWriter, req *http.Request) {
	t, err := nrsc.LoadTemplates(nil, "t.html")
	if err != nil {
		http.NotFound(w, req)
	if err = t.Execute(w, params{7}); err != nil {
		http.NotFound(w, req)

func main() {
	http.HandleFunc("/", indexHandler)
	if err := http.ListenAndServe(":8080", nil); err != nil {
		fmt.Fprintf(os.Stderr, "error: %s\n", err)


Package Files

doc.go nrsc.go


const (
    Version = "0.4.1"


var ResourceMap map[string]Resource = nil

func Handle Uses

func Handle(prefix string) error

Handle register HTTP handler under prefix

func Initialize Uses

func Initialize() error

func LoadTemplates Uses

func LoadTemplates(t *template.Template, filenames ...string) (*template.Template, error)

LoadTemplates loads named templates from resources. If the argument "t" is nil, it is created from the first resource.

func Mask Uses

func Mask(mask *regexp.Regexp)

Mask masks URLs from being served (the HTTP server will return 401 Unauthorized)

type Resource Uses

type Resource interface {
    Name() string
    Open() (io.ReadCloser, error)
    Size() int64
    ModTime() time.Time

func Get Uses

func Get(path string) Resource

Get returns the named resource (nil if not found)



Package nrsc imports 14 packages (graph) and is imported by 1 packages. Updated 2017-11-25. Refresh now. Tools for package owners.