assets-life

command module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: MIT Imports: 7 Imported by: 0

README

Build Status

assets-life

assets-life is a very simple embedding asset generator. It generates an embed small in-memory file system that is served from an http.FileSystem.

Usage

Install the command line tool first.

go get github.com/shogo82148/assets-life

The assets-life command generates a package that have embed small in-memory file system.

assets-life /path/to/your/project/public public

You can access the file system by accessing a public variable Root of the generated package.

import (
    "net/http"
    "./public" // TODO: Replace with the absolute import path
)

func main() {
    http.Handle("/", http.FileServer(public.Root))
    http.ListenAndServe(":8080", nil)
}

Visit http://localhost:8080/path/to/file to see your file.

The assets-life command also embed go:generate directive into generated code, and assets-life itself. It allows you to re-generate the package using go generate.

go generate ./public

The assets-life command is no longer needed because it is embedded into the generated package.

Documentation

Overview

assets-life is a very simple embedding asset generator. It generates an embed small in-memory file system that is served from an http.FileSystem. Install the command line tool first.

go get github.com/shogo82148/assets-life

The assets-life command generates a package that have embed small in-memory file system.

assets-life /path/to/your/project/public public

You can access the file system by accessing a public variable Root of the generated package.

import (
    "net/http"
    "./public" // TODO: Replace with the absolute import path
)

func main() {
    http.Handle("/", http.FileServer(public.Root))
    http.ListenAndServe(":8080", nil)
}

Visit http://localhost:8080/path/to/file to see your file.

The assets-life command also embed go:generate directive into generated code, and assets-life itself. It allows you to re-generate the package using go generate.

go generate ./public

The assets-life command is no longer needed because it is embedded into the generated package.

Jump to

Keyboard shortcuts

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