Socket
Book a DemoInstallSign in
Socket

zgo.at/zpack

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zgo.at/zpack

Go
Version
v1.0.1
Version published
Created
Source

Build Status codecov GoDoc

zpack is yet another way to pack static data in Go binaries.

Why? Because I don't like relying on external binaries, and many other solutions do. zpack just writes data to the specified file as []byte().

Basic usage:

// +build go_run_only

package main

import (
    "fmt"
    "os"

    "zgo.at/zpack"
)

func main() {
    err := zpack.Pack(map[string]map[string]string{
        // Pack ./db/schema.sql in ./db/pack.go as the variable "Schema".
        "./db/pack.go": map[string]string{
            "Schema": "./db/schema.sql",
        },

        // Pack all files in the "./public" and "./tpl" directories.
        "./handlers/pack.go": map[string]string{
            "packPublic": "./public",
            "packTpl":    "./tpl",
        },
    })
    if err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
}

Then go generate ./... and presto!

FAQs

Package last updated on 07 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts