Categorygithub.com/rvflash/combine
modulepackage
0.0.5
Repository: https://github.com/rvflash/combine.git
Documentation: pkg.go.dev

# README

Combine

GoDoc Build Status Code Coverage Go Report Card

Package combine provides interface to create assets with multiple source of contents (bytes, string, file path or URL). It combines and minifies them on the fly on the first demand on the dedicated file server.

Installation

$ go get github.com/rvflash/combine
$ cd $GOPATH/src/github.com/rvflash/combine
$ dep ensure

Usage

See example for real usage. Errors are ignored for the demo.

import "github.com/rvflash/combine"
// ...
// Creates a box with the path to the local file resources
// and the path to store combined / minified assets.
static := combine.NewBox("./src", "./combine")
// Deletes all files cache on exit. 
defer func() { _ = static.Close() }()
// ...
// Creates a asset.
css := static.NewCSS()
_ = css.AddURL("https://raw.githubusercontent.com/twbs/bootstrap/v4-dev/dist/css/bootstrap-reboot.css")
_ = css.AddString(".blue{ color: #4286f4; }")
_ = css.AddFile("local/file/is_src_dir.css")
// Uses it in a HTML template by retrieving its path or tag.
// By default, a build version will also added.
tag := css.Tag("/static/")
// ...
// Serves combined and minifed resousrces
http.Handle("/static/", http.FileServer(static))
http.ListenAndServe(":8080", nil)

# Packages

No description provided by the author

# Functions

NewBox returns a new instance of Box.

# Constants

CSS is the MIME type for CSS content.
CSS is the MIME type for JavaScript content.

# Variables

ErrExist is returned when asset already exists.
ErrMime is returned ii the mime type is not managed.
ErrNotFound is returned ii the asset is not found.
ErrUnexpectedEOF means that the asset is empty.

# Structs

Box represent a virtual folder to store or retrieve combined and minified assets.
Static represents the minified and combined version of the asset.

# Interfaces

Aggregator is the interface implemented by asset to add content inside.
Combiner must be implement to combine minified contents.
File ...
HTTPGetter represents the mean to get data from HTTP.
StringCombiner ...
Tagger must be implemented by an asset to be used in HTML5.

# Type aliases

Dir defines the current workspace.