grandet

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2017 License: BSD-3-Clause Imports: 7 Imported by: 0

README

grandet

GoDoc Go Report Card

another golang assets handler, I made this just because the other solutions are already dead.

usage

go get github.com/setekhid/grandet/grandet
grandet \
	-i github.com/setekhid/grandet/assets \
	-d $GOPATH/src/github.com/setekhid/grandet/assets \
	$GOPATH/src/github.com/setekhid/grandet/assets/asset.go.tmpl \
	$GOPATH/src/github.com/setekhid/grandet/assets/grandet.go.tmpl
# gofmt as you like
package assets

func init() {
	// regist all local assets
	(&grandetAssets{}).registAssets()
}
package main

import (
	"github.com/setekhid/grandet/assets"
	"githbu.com/setekhid/grandet/pkg/http"
)

func main() {
	content := assets.Grandet.Asset("asset.go.tmpl")
	_ = content
	file := http.Fs.Open("/github.com/setekhid/grandet/assets/asset.go.tmpl")
	_ = file
}

license

this project is under bsd 3-clause license, see LICENSE file

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Asset return an asset from the Barn instance
	Asset = barn.Asset
	// ModTime return the modified time of an asset
	ModTime = barn.ModTime
	// Foldl loop all assets in Barn
	Foldl = barn.Foldl
	// FoldlNames loop all asset names in Barn
	FoldlNames = barn.FoldlNames
	// Grandet return the Grandet object of the asset package
	Grandet = barn.Grandet
	// Branches return the branch names of specific path
	Branches = barn.Branches
)
View Source
var ModBeginningTime = time.Unix(0, 0)

ModBeginningTime is the very beginning of computer time

Functions

This section is empty.

Types

type Assets

type Assets interface {

	// Asset get an asset by name, if doesn't exists, return nil
	Asset(name string) (content []byte)

	// ModTime return the last modified time of asset
	ModTime(name string) time.Time

	// Foldl fold all assets in this Assets with value
	Foldl(
		value interface{},
		process func(
			value interface{}, name string, content []byte,
		) (result interface{}),
	) (result interface{})

	// FoldlNames fold all asset names in this Assets
	FoldlNames(
		value interface{},
		process func(value interface{}, name string) (result interface{}),
	) (result interface{})
}

Assets is the interface for directly asset accessing, the return value may not be your original content.

type AssetsImpl

type AssetsImpl struct {
	// contains filtered or unexported fields
}

AssetsImpl provide the implementation of Assets

func (*AssetsImpl) Asset

func (ga *AssetsImpl) Asset(name string) []byte

Asset implement Assets#Asset

func (*AssetsImpl) Foldl

func (ga *AssetsImpl) Foldl(

	value interface{},
	process func(interface{}, string, []byte) interface{},

) interface{}

Foldl implement Assets#Foldl

func (*AssetsImpl) FoldlNames

func (ga *AssetsImpl) FoldlNames(

	value interface{},
	process func(interface{}, string) interface{},

) interface{}

FoldlNames implement Assets#FoldlNames

func (*AssetsImpl) Init

func (ga *AssetsImpl) Init(pkg_import string)

Init initialize AssetsImpl

func (*AssetsImpl) ModTime

func (ga *AssetsImpl) ModTime(name string) time.Time

ModTime implement Assets#ModTime

func (*AssetsImpl) RegistAsset

func (ga *AssetsImpl) RegistAsset(
	name string, content []byte, modtime time.Time,
)

RegistAsset register an asset into grandet

type Barn

type Barn interface {
	Assets
	Grandet(pkg_import string) Assets
	Branches(pkg_import string) []string
}

Barn collects all imported Grandet assets

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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