Documentation ¶
Index ¶
- Constants
- type Asset
- func (a *Asset) Bytes() ([]byte, error)
- func (a *Asset) EnsureHash() error
- func (a *Asset) EnsureHashWithWD(wd string) error
- func (a *Asset) Equals(other *Asset) bool
- func (a *Asset) GetPath() (string, bool)
- func (a *Asset) GetText() (string, bool)
- func (a *Asset) GetURI() (string, bool)
- func (a *Asset) GetURIURL() (*url.URL, bool, error)
- func (a *Asset) HasContents() bool
- func (a *Asset) IsPath() bool
- func (a *Asset) IsText() bool
- func (a *Asset) IsURI() bool
- func (a *Asset) Read() (*Blob, error)
- func (a *Asset) ReadWithWD(wd string) (*Blob, error)
- func (a *Asset) Serialize() map[string]interface{}
- type Blob
Constants ¶
const ( AssetSig = sig.AssetSig AssetHashProperty = "hash" // the dynamic property for an asset's hash. AssetTextProperty = "text" // the dynamic property for an asset's text. AssetPathProperty = "path" // the dynamic property for an asset's path. AssetURIProperty = "uri" // the dynamic property for an asset's URI. )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Asset ¶
type Asset struct { // Sig is the unique asset type signature (see properties.go). Sig string `json:"4dabf18193072939515e22adb298388d" yaml:"4dabf18193072939515e22adb298388d"` // Hash is the SHA256 hash of the asset's contents. Hash string `json:"hash,omitempty" yaml:"hash,omitempty"` // Text is set to a non-empty value for textual assets. Text string `json:"text,omitempty" yaml:"text,omitempty"` // Path will contain a non-empty path to the file on the current filesystem for file assets. Path string `json:"path,omitempty" yaml:"path,omitempty"` // URI will contain a non-empty URI (file://, http://, https://, or custom) for URI-backed assets. URI string `json:"uri,omitempty" yaml:"uri,omitempty"` }
Asset is a serialized asset reference. It is a union: thus, at most one of its fields will be non-nil. Several helper routines exist as members in order to easily interact with the assets referenced by an instance of this type.
func Deserialize ¶
DeserializeAsset checks to see if the map contains an asset, using its signature, and if so deserializes it.
func FromPath ¶
FromPath produces a new asset and its corresponding SHA256 hash from the given filesystem path.
func FromPathWithWD ¶ added in v3.115.0
FromPathWithWD produces a new asset and its corresponding SHA256 hash from the given filesystem path.
func FromText ¶
FromText produces a new asset and its corresponding SHA256 hash from the given text.
func FromURI ¶
FromURI produces a new asset and its corresponding SHA256 hash from the given network URI.
func (*Asset) EnsureHash ¶
EnsureHash computes the SHA256 hash of the asset's contents and stores it on the object.
func (*Asset) EnsureHashWithWD ¶ added in v3.115.0
EnsureHash computes the SHA256 hash of the asset's contents and stores it on the object.
func (*Asset) Equals ¶
Equals returns true if a is value-equal to other. In this case, value equality is determined only by the hash: even if the contents of two assets come from different sources, they are treated as equal if their hashes match. Similarly, if the contents of two assets come from the same source but the assets have different hashes, the assets are not equal.
func (*Asset) GetURIURL ¶
GetURIURL returns the underlying URI as a parsed URL, provided it is one. If there was an error parsing the URI, it will be returned as a non-nil error object.
func (*Asset) HasContents ¶
HasContents indicates whether or not an asset's contents can be read.
func (*Asset) ReadWithWD ¶ added in v3.115.0
ReadWithWD begins reading an asset.
type Blob ¶
type Blob struct {
// contains filtered or unexported fields
}
Blob is a blob that implements ReadCloser and offers Len functionality.
func NewFileBlob ¶
NewFileBlob creates a new asset blob whose size is known thanks to stat.
func NewRawBlob ¶
func NewRawBlob(r io.ReadCloser, size int64) *Blob
func NewReadCloserBlob ¶
func NewReadCloserBlob(r io.ReadCloser) (*Blob, error)
NewReadCloserBlob turn any old ReadCloser into an Blob, usually by making a copy.