diff --git a/bootstrap/assets.go b/bootstrap/assets.go new file mode 100644 index 0000000..7e12a54 --- /dev/null +++ b/bootstrap/assets.go @@ -0,0 +1,15 @@ +package bootstrap + +import "github.com/rocketsoftware/open-web-launch/gui" + +//go:generate go-bindata-assetfs -pkg bootstrap assets/... +type assets struct { +} + +func (*assets) Get(name string) ([]byte, error) { + return Asset(name) +} + +func init() { + gui.Assets = &assets{} +} diff --git a/gui/assets/Icon64.png b/bootstrap/assets/Icon64.png similarity index 100% rename from gui/assets/Icon64.png rename to bootstrap/assets/Icon64.png diff --git a/gui/bindata.go b/bootstrap/bindata.go similarity index 99% rename from gui/bindata.go rename to bootstrap/bindata.go index a3f88ec..38bba6c 100644 --- a/gui/bindata.go +++ b/bootstrap/bindata.go @@ -6,7 +6,7 @@ // assets/main.js // DO NOT EDIT! -package gui +package bootstrap import ( "github.com/elazarl/go-bindata-assetfs" diff --git a/gui/.gitignore b/gui/.gitignore deleted file mode 100644 index 459d0de..0000000 --- a/gui/.gitignore +++ /dev/null @@ -1 +0,0 @@ -bindata.go \ No newline at end of file diff --git a/gui/assets.go b/gui/assets.go new file mode 100644 index 0000000..805a680 --- /dev/null +++ b/gui/assets.go @@ -0,0 +1,22 @@ +package gui + +import "errors" + +// AssetGetter provide an interface to retrieve binary asssets packaged with the binary. +type AssetGetter interface { + // Get the asset by name. Returns an error if it does not exist, or if it otherwise + // runs into a problem retrieving it. + Get(name string) ([]byte, error) +} + +// Assets holds the AssetFetcher which can retrieve assets for the binary +var Assets AssetGetter + +// Asset retrieves an asset by name from the provisioned AssetGetter. +func Asset(name string) ([]byte, error) { + if Assets == nil { + return nil, errors.New("no assets provided") + } + + return Assets.Get(name) +} diff --git a/gui/gui.go b/gui/gui.go index 1243ca4..f3d597d 100644 --- a/gui/gui.go +++ b/gui/gui.go @@ -1,6 +1,5 @@ package gui -//go:generate go-bindata-assetfs -pkg gui assets/... import ( "bytes"