Merge pull request #73 from jbreitbart/master

Added MustAsset function.
pull/4/head
Jim Teeuwen 2015-03-08 22:15:58 +01:00
commit 040617c5ef
1 changed files with 11 additions and 0 deletions

11
toc.go
View File

@ -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.