Documentation ¶
Overview ¶
Package site holds binary resources embedded into Go executable
Index ¶
- Variables
- func CopyTo(target string, mode os.FileMode, overwrite bool, files ...string) error
- func HTTPHandlerWithPrefix(prefix string) func(http.ResponseWriter, *http.Request)
- func HttpFileSystem() http.FileSystem
- type Asset
- func (a *Asset) Bytes() []byte
- func (a *Asset) IsCompressed() bool
- func (a *Asset) IsDir() bool
- func (a *Asset) MimeType() string
- func (a *Asset) ModTime() time.Time
- func (a *Asset) Mode() os.FileMode
- func (a *Asset) Name() string
- func (a *Asset) RawBytes() []byte
- func (a *Asset) Reader() io.ReadCloser
- func (a *Asset) Size() int64
- func (a *Asset) String() string
- func (a *Asset) Sys() interface{}
- func (a *Asset) WriteTo(w io.Writer) (int64, error)
- type File
- type FileSystem
Constants ¶
This section is empty.
Variables ¶
var ServeHTTP = HTTPHandlerWithPrefix("")
ServeHTTP provides a convenience handler whenever embedded content should be served from the root URI.
Functions ¶
func CopyTo ¶ added in v1.1.0
The CopyTo method extracts all mentioned files to a specified location, keeping directory structure. If supplied file is a directory, than it will be extracted recursively. CopyTo with no file mentioned will extract the whole content of the embedded filesystem. CopyTo returns error if there is a file with the same name at the target location, unless overwrite is set to true, or file has the same size and modification file as the extracted file. site.CopyTo(".", mode, false) will effectively extract content of the filesystem to the current directory (which makes it the most space-wise inefficient self-extracting archive ever).
func HTTPHandlerWithPrefix ¶
func HTTPHandlerWithPrefix(prefix string) func(http.ResponseWriter, *http.Request)
HTTPHandlerWithPrefix provides a simple way to serve embedded content via Go standard HTTP server and returns an http handler function. The "prefix" will be stripped from the request URL to serve embedded content from non-root URI
func HttpFileSystem ¶
func HttpFileSystem() http.FileSystem
Types ¶
type Asset ¶
type Asset struct {
// contains filtered or unexported fields
}
Asset represents binary resource stored within Go executable. Asset implements fmt.Stringer and io.WriterTo interfaces, decompressing binary data if necessary.
func (*Asset) IsCompressed ¶
IsCompressed returns true of asset has been compressed
func (*Asset) ModTime ¶
ModTime implements os.FileInfo and returns the time stamp when this package has been produced (the same value for all the assets)
func (*Asset) RawBytes ¶ added in v1.1.0
RawBytes returns a raw byte slice of the asset. Changing content of slice will result into segfault.
func (*Asset) Reader ¶ added in v1.1.0
func (a *Asset) Reader() io.ReadCloser
Returns content of the asset as io.ReaderCloser.
func (*Asset) Size ¶
Size implements os.FileInfo and returns the size of the asset (uncompressed, if asset has been compressed)
type File ¶
type File interface { io.Closer io.Reader io.Seeker Readdir(count int) ([]os.FileInfo, error) Stat() (os.FileInfo, error) }
A File is returned by virtual FileSystem's Open method. The methods should behave the same as those on an *os.File.
type FileSystem ¶ added in v1.1.0
type FileSystem interface { Open(name string) (File, error) Stat(name string) (os.FileInfo, error) // As in filepath.Walk Walk(root string, walkFunc filepath.WalkFunc) error // Returns http.FileSystem interface to use with http.Server HttpFileSystem() http.FileSystem }
A simple FileSystem abstraction
func NewUnionFS ¶ added in v1.1.0
func NewUnionFS(src string) (FileSystem, error)