Skip to content

abstract asset storage #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions bootstrap/assets.go
Original file line number Diff line number Diff line change
@@ -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{}
}
File renamed without changes
2 changes: 1 addition & 1 deletion gui/bindata.go → bootstrap/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion gui/.gitignore

This file was deleted.

22 changes: 22 additions & 0 deletions gui/assets.go
Original file line number Diff line number Diff line change
@@ -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)
}
1 change: 0 additions & 1 deletion gui/gui.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package gui

//go:generate go-bindata-assetfs -pkg gui assets/...

import (
"bytes"
Expand Down