essence

command module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2020 License: MIT Imports: 3 Imported by: 0

README

Essence

Essence is a virtual file system implementation for serving static content from a go web application. The content is converted to binary and stored within the go web application binary executable file.

The purpose is to bundle content together into the binary executable for easier deployment as well as having the content served from memory rather than first retrieved from disk.

This module contains a package called vfs that is referenced within application code when interacting with the virtual file system. You should never have to interact with this package directly as all references to it will be part of the generated code that essence creates when building the virtual file system code.

Installation

Install the binary as any other golang application:

go install github.com/acepukas/essence

After which the essence binary will be on your $GOPATH.

Usage

You can place code generation directives in your application code. For example:

//go:generate essence -package-name=static_vfs -src-dir=./static

When static content changes you must rerun the go generate command each time.

Within your application you can then import the generated package (static_vfs in this example):

import (

  ...

  vfs "github.com/acepukas/bookmarks/static_vfs"

)

Then refer to the virtual file system with

vfs.VFS

...

fileServer := http.FileServer(vfs.VFS)

...

When building the web application binary you can specify on the command line the "dev" tag to use the on disk file system while in development:

go build -tags dev

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
go build -tags dev
go build -tags dev
vfs is a virtual file system implementation
vfs is a virtual file system implementation

Jump to

Keyboard shortcuts

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