diff --git a/examples/2048/2048/board.go b/examples/2048/2048/board.go index c52cb3a73..ebd3679de 100644 --- a/examples/2048/2048/board.go +++ b/examples/2048/2048/board.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build example + package twenty48 import ( diff --git a/examples/2048/2048/colors.go b/examples/2048/2048/colors.go index 588164b44..3f9772094 100644 --- a/examples/2048/2048/colors.go +++ b/examples/2048/2048/colors.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build example + package twenty48 import ( diff --git a/examples/2048/2048/game.go b/examples/2048/2048/game.go index b3116a6b5..9cf15aa46 100644 --- a/examples/2048/2048/game.go +++ b/examples/2048/2048/game.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build example + package twenty48 import ( diff --git a/examples/2048/2048/input.go b/examples/2048/2048/input.go index 11682de43..4831c94d4 100644 --- a/examples/2048/2048/input.go +++ b/examples/2048/2048/input.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build example + package twenty48 import ( diff --git a/examples/2048/2048/tile.go b/examples/2048/2048/tile.go index 944ea9c7c..2ac73c088 100644 --- a/examples/2048/2048/tile.go +++ b/examples/2048/2048/tile.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build example + package twenty48 import ( diff --git a/examples/2048/2048/tile_test.go b/examples/2048/2048/tile_test.go index 6b7201c18..d11259617 100644 --- a/examples/2048/2048/tile_test.go +++ b/examples/2048/2048/tile_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build example + package twenty48_test import ( diff --git a/examples/blocks/blocks/field.go b/examples/blocks/blocks/field.go index 9d96c82c9..5795d851e 100644 --- a/examples/blocks/blocks/field.go +++ b/examples/blocks/blocks/field.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build example + package blocks import ( diff --git a/examples/blocks/blocks/font.go b/examples/blocks/blocks/font.go index c01cbe68e..372889956 100644 --- a/examples/blocks/blocks/font.go +++ b/examples/blocks/blocks/font.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build example + package blocks import ( diff --git a/examples/blocks/blocks/game.go b/examples/blocks/blocks/game.go index b5ae0b453..1768cf661 100644 --- a/examples/blocks/blocks/game.go +++ b/examples/blocks/blocks/game.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build example + package blocks import ( diff --git a/examples/blocks/blocks/gamepad.go b/examples/blocks/blocks/gamepad.go index b418434ae..e6782baa0 100644 --- a/examples/blocks/blocks/gamepad.go +++ b/examples/blocks/blocks/gamepad.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build example + package blocks import ( diff --git a/examples/blocks/blocks/gamescene.go b/examples/blocks/blocks/gamescene.go index 4612b197c..675f5374a 100644 --- a/examples/blocks/blocks/gamescene.go +++ b/examples/blocks/blocks/gamescene.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build example + package blocks import ( diff --git a/examples/blocks/blocks/input.go b/examples/blocks/blocks/input.go index e83e202bd..b2a20dcf8 100644 --- a/examples/blocks/blocks/input.go +++ b/examples/blocks/blocks/input.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build example + package blocks import ( diff --git a/examples/blocks/blocks/piece.go b/examples/blocks/blocks/piece.go index 955c887a6..b45fece92 100644 --- a/examples/blocks/blocks/piece.go +++ b/examples/blocks/blocks/piece.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build example + package blocks import ( diff --git a/examples/blocks/blocks/scenemanager.go b/examples/blocks/blocks/scenemanager.go index 82d5bdd93..db53c0264 100644 --- a/examples/blocks/blocks/scenemanager.go +++ b/examples/blocks/blocks/scenemanager.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build example + package blocks import ( diff --git a/examples/blocks/blocks/titlescene.go b/examples/blocks/blocks/titlescene.go index 45e592b96..fc7f002d3 100644 --- a/examples/blocks/blocks/titlescene.go +++ b/examples/blocks/blocks/titlescene.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build example + package blocks import ( diff --git a/examples/common/font.go b/examples/common/font.go index 3d7e3e6fe..fd3dd4c30 100644 --- a/examples/common/font.go +++ b/examples/common/font.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build example + package common import ( diff --git a/examples/common/internal/assets/assets.go b/examples/common/internal/assets/assets.go index 2cf30b67d..ec84cc352 100644 --- a/examples/common/internal/assets/assets.go +++ b/examples/common/internal/assets/assets.go @@ -12,7 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:generate go-bindata -nocompress -pkg=assets arcadefont.png +// +build example + +//go:generate go-bindata -nocompress -pkg=assets -tags=example arcadefont.png //go:generate gofmt -s -w . package assets diff --git a/examples/common/internal/assets/bindata.go b/examples/common/internal/assets/bindata.go index 44bed97c7..7afcd7783 100644 --- a/examples/common/internal/assets/bindata.go +++ b/examples/common/internal/assets/bindata.go @@ -1,10 +1,16 @@ +// Code generated by go-bindata. +// sources: +// arcadefont.png +// DO NOT EDIT! + +// +build example + package assets import ( "fmt" "io/ioutil" "os" - "path" "path/filepath" "strings" "time" @@ -15,45 +21,45 @@ type asset struct { info os.FileInfo } -type bindata_file_info struct { +type bindataFileInfo struct { name string size int64 mode os.FileMode modTime time.Time } -func (fi bindata_file_info) Name() string { +func (fi bindataFileInfo) Name() string { return fi.name } -func (fi bindata_file_info) Size() int64 { +func (fi bindataFileInfo) Size() int64 { return fi.size } -func (fi bindata_file_info) Mode() os.FileMode { +func (fi bindataFileInfo) Mode() os.FileMode { return fi.mode } -func (fi bindata_file_info) ModTime() time.Time { +func (fi bindataFileInfo) ModTime() time.Time { return fi.modTime } -func (fi bindata_file_info) IsDir() bool { +func (fi bindataFileInfo) IsDir() bool { return false } -func (fi bindata_file_info) Sys() interface{} { +func (fi bindataFileInfo) Sys() interface{} { return nil } -var _arcadefont_png = []byte("\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x80\x00\x00\x000\b\x03\x00\x00\x00\xee*\x82\x8c\x00\x00\x00\x06PLTE\x00\x00\x00\xff\xff\xff\xa5ٟ\xdd\x00\x00\x00\x01tRNS\x00@\xe6\xd8f\x00\x00\x03\x98IDATx\x9c\xc4X\x89\x96\xac(\f\xe5\xd6\xf3\xff\u007f9\xd3B\x96\x9b\x18ѩ\xe99/ݥ\x82\x81\xec\v~F\x00\xa0\xd7\xf5\x10\xf3t=\xdf#\xe1\xdbCY\xf4\x0e0>\xbb\x97F\xf9\xdc{\x8e\xe6\xbf\b*\xa2\xfc\\%X,\xf7\r\ti\x18\x90\xf9\xbf(bm#sNN|\xdeW\x98\xbes\x80W\xa4\x8d~B];\xc1\t\x89\x13\x14ǧ\xa1\x8e\x9d\x01{P\x04\x10\x8f\xa3\x19\xfbz\x9a@\x1e\x99\xb5\xf5\x0e\xffG\xc2,>\x01\xb2]\xb7o\xe6(\x99@\x12G2\xff\xd6rӌ\x8b!\t\xd1\xe8\x89\tYE\xeb\x04\xbd\xc8\u007f\xef\xc7H\x174a\xf2\x10\x05\xd5i\xff\x85\x9b\xfc\nli\x81\x9d,9\xcfZ\xa63\x92\x87\x11s\xa2\xc3\xceɈ\x884\x83\xb5\xf0ϴm(y\xbd\a*G\x8d\xaf\x8b\xe5\x05\xba[*\x1b\xe9^\x9c?6\xfcy<&\x1f8=B\xc02\x12}\x01q\x1cQOq\xbb\x85\x88N\xf5\xd0I\xcd\xe5Q\t$cJ\"\xc8҇)HA\xc1u\xe3\xda\xd79\x90͏f\xc1\xf0x\x82\xe5*\x962\xe6]A\xb0\x90\xbd\xec\xef\x02\x93\x8f\xa4\xf7\x87\xaa\x9f\xe9',SM#Hp\xd4\x1b\xdb^'\x95\x13\x96\xf1\x85\xa4\xc2\xe4\xdd\xccj\x8a\x8eb1\x9b/\xf4!\rc1\xd8\xc8\xf4;\xf0*׀\x95~\t\u007fR\x84i\xc65\xa4o܉\xd9\t\x91\xe69l\v\xfe\xe9\x84ӟ\xf4\xa5\x19\vP\xf7_\xfe\x91\x8d\xd8\xe9u\x8c\xceM\xf2\x04,\x9c\x89!\xc8g\xe6!wd\xe4Œ*\xfdf\xf3\x16*Jۨ\x1c\xc1\x19\xe3u\x9b\xe7\xfc\xa03ro\xea{\x16\x91\x198ŧ\xfc\xe7q^\xa1\x98`P\xee\xbc+\xa3\xb9\xbe\xab\xa4Y\xde\xcf\xe9\x15K\xd3\"\x97*\x0f\xdc\xcaҙe\xe2rdž\a\tƩ\x01A\xed\x94\x16\x8e\x00T\fǥ\xdcI\xd3;ώ5R)\xa9\xb6\xe8\u0096\xffω\xe0\r\x1c\x1e\xbe*`\x1a\xa7\f\x99㸉k\x89b\x15\x1b \xf2^nn\x15>\xcb\xf63\fE\xbb\v\x1f\xeb\xb0v\x8b\x05\x90L-\xe4J\"\xe4r\"-\xfe\xe6`\xf2@7U\x81\xeaD\\\xc6(=\xe2(%\x83\x9e\x904\xb5\xf0y\xd9y\x8f<`\x89P3 \xf8>bl\x89\x11\x1e\xcd\"\xa5\xdc\\m\xa2\xb3\x9eZi\xffc\xa7\xa9\xbe\xa1y\v\xef\x9aރ\xd1+\x89\x8b\b:\x13\x88m\xf4`|\x17\xb6\x86\x83U\xc9.\x85\xcb\xf0/\x06\xc6@\x0e\xb7`\xa3\x8f\x11o|\xac#BtP\x89\xfe\x068\x80\x81Z\xd9\xea'\x9d\xd4s\xc8`\r'\u007f\x18\xe3\xe2\x03\x86\xd9Z䖁o\xe1\xcb\xf8\xff'\x00\x00\xff\xff\"\xd9\xedҰ\xcb\xea\x95\x00\x00\x00\x00IEND\xaeB`\x82") +var _arcadefontPng = []byte("\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x80\x00\x00\x000\b\x03\x00\x00\x00\xee*\x82\x8c\x00\x00\x00\x06PLTE\x00\x00\x00\xff\xff\xff\xa5\u065f\xdd\x00\x00\x00\x01tRNS\x00@\xe6\xd8f\x00\x00\x03\x98IDATx\x9c\xc4X\x89\x96\xac(\f\xe5\xd6\xf3\xff\u007f9\xd3B\x96\x9b\x18\u0469\xe99/\u0765\x82\x81\xec\v~F\x00\xa0\xd7\xf5\x10\xf3t=\xdf#\xe1\xdbCY\xf4\x0e0>\xbb\x97F\xf9\xdc{\x8e\xe6\xbf\b*\xa2\xfc\\%X,\xf7\r\ti\x18\x90\xf9\xbf(bm#sNN|\xdeW\x98\xbes\x80W\xa4\x8d~B];\xc1\t\x89\x13\x14\u01e7\xa1\x8e\x9d\x01{P\x04\x10\x8f\xa3\x19\xfbz\x9a@\x1e\x99\xb5\xf5\x0e\xffG\xc2,>\x01\xb2]\xb7o\xe6(\x99@\x12G2\xff\xd6r\u04cc\x8b!\t\xd1\xe8\x89\tYE\xeb\x04\xbd\xc8\u007f\xef\xc7H\x174a\xf2\x10\x05\xd5i\xff\x85\x9b\xfc\nli\x81\x9d,9\xcfZ\xa63\x92\x87\x11s\xa2\xc3\xce\u0248\x884\x83\xb5\xf0\u03f4m(y\xbd\a*G\x8d\xaf\x8b\xe5\x05\xba[*\x1b\xe9^\x9c?6\xfcy<&\x1f8=B\xc02\x12}\x01q\x1cQOq\xbb\x85\x88N\xf5\xd0I\xcd\xe5Q\t$cJ\"\xc8\u0487)HA\xc1u\xe3\xda\xd79\x90\u034ff\xc1\xf0x\x82\xe5*\x962\xe6]A\xb0\x90\xbd\xec\xef\x02\x93\x8f\xa4\xf7\x87\xaa\x9f\xe9',SM#Hp\xd4\x1b\xdb^'\x95\x13\x96\xf1\x85\xa4\xc2\xe4\xdd\xccj\x8a\x8eb1\x9b/\xf4!\rc1\xd8\xc8\xf4;\xf0*\u05c0\x95~\t\u007fR\x84i\xc65\xa4o\u0709\xd9\t\x91\xe69l\v\xfe\xe9\x84\u04df\xf4\xa5\x19\vP\xf7_\xfe\x91\x8d\xd8\xe9u\x8c\xceM\xf2\x04,\x9c\x89!\xc8g\xe6!wd\xe4\u0152*\xfdf\xf3\x16*J\u06e8\x1c\xc1\x19\xe3u\x9b\xe7\xfc\xa03ro\xea{\x16\x91\x198\u0167\xfc\xe7q^\xa1\x98`P\xee\xbc+\xa3\xb9\xbe\xab\xa4Y\xde\xcf\xe9\x15K\xd3\"\x97*\x0f\xdc\xca\u0499e\xe2r\u01c6\a\t\u01a9\x01A\xed\x94\x16\x8e\x00T\f\u01e5\xdcI\xd3;\u03ce5R)\xa9\xb6\xe8\u0096\xff\u03c9\xe0\r\x1c\x1e\xbe*`\x1a\xa7\f\x99\u3e09k\x89b\x15\x1b \xf2^nn\x15>\xcb\xf63\fE\xbb\v\x1f\xeb\xb0v\x8b\x05\x90L-\xe4J\"\xe4r\"-\xfe\xe6`\xf2@7U\x81\xeaD\\\xc6(=\xe2(%\x83\x9e\x904\xb5\xf0y\xd9y\x8f<`\x89P3 \xf8>bl\x89\x11\x1e\xcd\"\xa5\xdc\\m\xa2\xb3\x9eZi\xffc\xa7\xa9\xbe\xa1y\v\xef\x9a\u0783\xd1+\x89\x8b\b:\x13\x88m\xf4`|\x17\xb6\x86\x83U\xc9.\x85\xcb\xf0/\x06\xc6@\x0e\xb7`\xa3\x8f\x11o|\xac#BtP\x89\xfe\x068\x80\x81Z\xd9\xea'\x9d\xd4s\xc8`\r'\u007f\x18\xe3\xe2\x03\x86\xd9Z\u4581o\xe1\xcb\xf8\xff'\x00\x00\xff\xff\"\xd9\xed\u04b0\xcb\xea\x95\x00\x00\x00\x00IEND\xaeB`\x82") -func arcadefont_png_bytes() ([]byte, error) { - return _arcadefont_png, nil +func arcadefontPngBytes() ([]byte, error) { + return _arcadefontPng, nil } -func arcadefont_png() (*asset, error) { - bytes, err := arcadefont_png_bytes() +func arcadefontPng() (*asset, error) { + bytes, err := arcadefontPngBytes() if err != nil { return nil, err } - info := bindata_file_info{name: "arcadefont.png", size: 1008, mode: os.FileMode(420), modTime: time.Unix(1463226773, 0)} + info := bindataFileInfo{name: "arcadefont.png", size: 1008, mode: os.FileMode(420), modTime: time.Unix(1463226773, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -73,6 +79,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. @@ -99,7 +116,7 @@ func AssetNames() []string { // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ - "arcadefont.png": arcadefont_png, + "arcadefont.png": arcadefontPng, } // AssetDir returns the file names below a certain @@ -131,22 +148,22 @@ func AssetDir(name string) ([]string, error) { return nil, fmt.Errorf("Asset %s not found", name) } rv := make([]string, 0, len(node.Children)) - for name := range node.Children { - rv = append(rv, name) + for childName := range node.Children { + rv = append(rv, childName) } return rv, nil } -type _bintree_t struct { +type bintree struct { Func func() (*asset, error) - Children map[string]*_bintree_t + Children map[string]*bintree } -var _bintree = &_bintree_t{nil, map[string]*_bintree_t{ - "arcadefont.png": {arcadefont_png, map[string]*_bintree_t{}}, +var _bintree = &bintree{nil, map[string]*bintree{ + "arcadefont.png": {arcadefontPng, map[string]*bintree{}}, }} -// Restore an asset under the given directory +// RestoreAsset restores an asset under the given directory func RestoreAsset(dir, name string) error { data, err := Asset(name) if err != nil { @@ -156,7 +173,7 @@ func RestoreAsset(dir, name string) error { if err != nil { return err } - err = os.MkdirAll(_filePath(dir, path.Dir(name)), os.FileMode(0755)) + err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755)) if err != nil { return err } @@ -171,17 +188,18 @@ func RestoreAsset(dir, name string) error { return nil } -// Restore assets under the given directory recursively +// RestoreAssets restores an asset under the given directory recursively func RestoreAssets(dir, name string) error { children, err := AssetDir(name) - if err != nil { // File + // File + if err != nil { return RestoreAsset(dir, name) - } else { // Dir - for _, child := range children { - err = RestoreAssets(dir, path.Join(name, child)) - if err != nil { - return err - } + } + // Dir + for _, child := range children { + err = RestoreAssets(dir, filepath.Join(name, child)) + if err != nil { + return err } } return nil