Merge pull request #73 from jbreitbart/master
Added MustAsset function.
This commit is contained in:
commit
040617c5ef
11
toc.go
11
toc.go
|
@ -170,6 +170,17 @@ func Asset(name string) ([]byte, error) {
|
|||
return nil, fmt.Errorf("Asset %%s not found", name)
|
||||
}
|
||||
|
||||
// MustAsset is like Asset but panics when Asset would return an error.
|
||||
// It simplifies safe initialization of global variables.
|
||||
func MustAsset(name string) []byte {
|
||||
a, err := Asset(name)
|
||||
if (err != nil) {
|
||||
panic("asset: Asset(" + name + "): " + err.Error())
|
||||
}
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
// AssetInfo loads and returns the asset info for the given name.
|
||||
// It returns an error if the asset could not be found or
|
||||
// could not be loaded.
|
||||
|
|
Loading…
Reference in New Issue
Block a user