Fix go format of generated code
The following changes make the generated code go fmt compatible.
This commit is contained in:
parent
bfe36d3254
commit
8ed2cd0f6d
2
debug.go
2
debug.go
|
@ -32,9 +32,9 @@ func writeDebugHeader(w io.Writer) error {
|
||||||
_, err := fmt.Fprintf(w, `import (
|
_, err := fmt.Fprintf(w, `import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// bindataRead reads the given file from disk. It returns an error on failure.
|
// bindataRead reads the given file from disk. It returns an error on failure.
|
||||||
|
|
34
release.go
34
release.go
|
@ -103,11 +103,11 @@ func header_compressed_nomemcopy(w io.Writer) error {
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
|
||||||
"os"
|
|
||||||
"time"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func bindataRead(data, name string) ([]byte, error) {
|
func bindataRead(data, name string) ([]byte, error) {
|
||||||
|
@ -140,11 +140,11 @@ func header_compressed_memcopy(w io.Writer) error {
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
|
||||||
"os"
|
|
||||||
"time"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func bindataRead(data []byte, name string) ([]byte, error) {
|
func bindataRead(data []byte, name string) ([]byte, error) {
|
||||||
|
@ -174,13 +174,13 @@ func bindataRead(data []byte, name string) ([]byte, error) {
|
||||||
func header_uncompressed_nomemcopy(w io.Writer) error {
|
func header_uncompressed_nomemcopy(w io.Writer) error {
|
||||||
_, err := fmt.Fprintf(w, `import (
|
_, err := fmt.Fprintf(w, `import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"unsafe"
|
|
||||||
"os"
|
|
||||||
"time"
|
"time"
|
||||||
"io/ioutil"
|
"unsafe"
|
||||||
"path/filepath"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func bindataRead(data, name string) ([]byte, error) {
|
func bindataRead(data, name string) ([]byte, error) {
|
||||||
|
@ -201,11 +201,11 @@ func bindataRead(data, name string) ([]byte, error) {
|
||||||
func header_uncompressed_memcopy(w io.Writer) error {
|
func header_uncompressed_memcopy(w io.Writer) error {
|
||||||
_, err := fmt.Fprintf(w, `import (
|
_, err := fmt.Fprintf(w, `import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"os"
|
|
||||||
"time"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
`)
|
`)
|
||||||
return err
|
return err
|
||||||
|
@ -218,9 +218,9 @@ func header_release_common(w io.Writer) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
type bindataFileInfo struct {
|
type bindataFileInfo struct {
|
||||||
name string
|
name string
|
||||||
size int64
|
size int64
|
||||||
mode os.FileMode
|
mode os.FileMode
|
||||||
modTime time.Time
|
modTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +378,7 @@ func asset_release_common(w io.Writer, c *Config, asset *Asset) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: %q, size: %d, mode: os.FileMode(%d), modTime: time.Unix(%d, 0)}
|
info := bindataFileInfo{name: %q, size: %d, mode: os.FileMode(%d), modTime: time.Unix(%d, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
72
restore.go
72
restore.go
|
@ -13,49 +13,49 @@ func writeRestore(w io.Writer) error {
|
||||||
_, err := fmt.Fprintf(w, `
|
_, err := fmt.Fprintf(w, `
|
||||||
// RestoreAsset restores an asset under the given directory
|
// RestoreAsset restores an asset under the given directory
|
||||||
func RestoreAsset(dir, name string) error {
|
func RestoreAsset(dir, name string) error {
|
||||||
data, err := Asset(name)
|
data, err := Asset(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
info, err := AssetInfo(name)
|
info, err := AssetInfo(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
|
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
|
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RestoreAssets restores an asset under the given directory recursively
|
// RestoreAssets restores an asset under the given directory recursively
|
||||||
func RestoreAssets(dir, name string) error {
|
func RestoreAssets(dir, name string) error {
|
||||||
children, err := AssetDir(name)
|
children, err := AssetDir(name)
|
||||||
// File
|
// File
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return RestoreAsset(dir, name)
|
return RestoreAsset(dir, name)
|
||||||
}
|
}
|
||||||
// Dir
|
// Dir
|
||||||
for _, child := range children {
|
for _, child := range children {
|
||||||
err = RestoreAssets(dir, filepath.Join(name, child))
|
err = RestoreAssets(dir, filepath.Join(name, child))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _filePath(dir, name string) string {
|
func _filePath(dir, name string) string {
|
||||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||||
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
`)
|
`)
|
||||||
|
|
116
testdata/out/compress-memcopy.go
vendored
116
testdata/out/compress-memcopy.go
vendored
|
@ -13,11 +13,11 @@ import (
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
|
||||||
"os"
|
|
||||||
"time"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func bindataRead(data []byte, name string) ([]byte, error) {
|
func bindataRead(data []byte, name string) ([]byte, error) {
|
||||||
|
@ -46,9 +46,9 @@ type asset struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type bindataFileInfo struct {
|
type bindataFileInfo struct {
|
||||||
name string
|
name string
|
||||||
size int64
|
size int64
|
||||||
mode os.FileMode
|
mode os.FileMode
|
||||||
modTime time.Time
|
modTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,8 +86,8 @@ func inATestAsset() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "in/a/test.asset", size: 15, mode: os.FileMode(420), modTime: time.Unix(1431385279, 0)}
|
info := bindataFileInfo{name: "in/a/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,8 +106,8 @@ func inBTestAsset() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "in/b/test.asset", size: 15, mode: os.FileMode(420), modTime: time.Unix(1430781941, 0)}
|
info := bindataFileInfo{name: "in/b/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,8 +126,8 @@ func inCTestAsset() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "in/c/test.asset", size: 15, mode: os.FileMode(420), modTime: time.Unix(1430781941, 0)}
|
info := bindataFileInfo{name: "in/c/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,8 +146,8 @@ func inTestAsset() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "in/test.asset", size: 15, mode: os.FileMode(420), modTime: time.Unix(1430781941, 0)}
|
info := bindataFileInfo{name: "in/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ func Asset(name string) ([]byte, error) {
|
||||||
// It simplifies safe initialization of global variables.
|
// It simplifies safe initialization of global variables.
|
||||||
func MustAsset(name string) []byte {
|
func MustAsset(name string) []byte {
|
||||||
a, err := Asset(name)
|
a, err := Asset(name)
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
panic("asset: Asset(" + name + "): " + err.Error())
|
panic("asset: Asset(" + name + "): " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,72 +245,68 @@ func AssetDir(name string) ([]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type bintree struct {
|
type bintree struct {
|
||||||
Func func() (*asset, error)
|
Func func() (*asset, error)
|
||||||
Children map[string]*bintree
|
Children map[string]*bintree
|
||||||
}
|
}
|
||||||
var _bintree = &bintree{nil, map[string]*bintree{
|
var _bintree = &bintree{nil, map[string]*bintree{
|
||||||
"in": &bintree{nil, map[string]*bintree{
|
"in": &bintree{nil, map[string]*bintree{
|
||||||
"a": &bintree{nil, map[string]*bintree{
|
"a": &bintree{nil, map[string]*bintree{
|
||||||
"test.asset": &bintree{inATestAsset, map[string]*bintree{
|
"test.asset": &bintree{inATestAsset, map[string]*bintree{}},
|
||||||
}},
|
|
||||||
}},
|
}},
|
||||||
"b": &bintree{nil, map[string]*bintree{
|
"b": &bintree{nil, map[string]*bintree{
|
||||||
"test.asset": &bintree{inBTestAsset, map[string]*bintree{
|
"test.asset": &bintree{inBTestAsset, map[string]*bintree{}},
|
||||||
}},
|
|
||||||
}},
|
}},
|
||||||
"c": &bintree{nil, map[string]*bintree{
|
"c": &bintree{nil, map[string]*bintree{
|
||||||
"test.asset": &bintree{inCTestAsset, map[string]*bintree{
|
"test.asset": &bintree{inCTestAsset, map[string]*bintree{}},
|
||||||
}},
|
|
||||||
}},
|
|
||||||
"test.asset": &bintree{inTestAsset, map[string]*bintree{
|
|
||||||
}},
|
}},
|
||||||
|
"test.asset": &bintree{inTestAsset, map[string]*bintree{}},
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
|
|
||||||
// RestoreAsset restores an asset under the given directory
|
// RestoreAsset restores an asset under the given directory
|
||||||
func RestoreAsset(dir, name string) error {
|
func RestoreAsset(dir, name string) error {
|
||||||
data, err := Asset(name)
|
data, err := Asset(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
info, err := AssetInfo(name)
|
info, err := AssetInfo(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
|
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
|
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RestoreAssets restores an asset under the given directory recursively
|
// RestoreAssets restores an asset under the given directory recursively
|
||||||
func RestoreAssets(dir, name string) error {
|
func RestoreAssets(dir, name string) error {
|
||||||
children, err := AssetDir(name)
|
children, err := AssetDir(name)
|
||||||
// File
|
// File
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return RestoreAsset(dir, name)
|
return RestoreAsset(dir, name)
|
||||||
}
|
}
|
||||||
// Dir
|
// Dir
|
||||||
for _, child := range children {
|
for _, child := range children {
|
||||||
err = RestoreAssets(dir, filepath.Join(name, child))
|
err = RestoreAssets(dir, filepath.Join(name, child))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _filePath(dir, name string) string {
|
func _filePath(dir, name string) string {
|
||||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||||
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
116
testdata/out/compress-nomemcopy.go
vendored
116
testdata/out/compress-nomemcopy.go
vendored
|
@ -13,11 +13,11 @@ import (
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
|
||||||
"os"
|
|
||||||
"time"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func bindataRead(data, name string) ([]byte, error) {
|
func bindataRead(data, name string) ([]byte, error) {
|
||||||
|
@ -46,9 +46,9 @@ type asset struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type bindataFileInfo struct {
|
type bindataFileInfo struct {
|
||||||
name string
|
name string
|
||||||
size int64
|
size int64
|
||||||
mode os.FileMode
|
mode os.FileMode
|
||||||
modTime time.Time
|
modTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,8 +86,8 @@ func inATestAsset() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "in/a/test.asset", size: 15, mode: os.FileMode(420), modTime: time.Unix(1431385279, 0)}
|
info := bindataFileInfo{name: "in/a/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,8 +106,8 @@ func inBTestAsset() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "in/b/test.asset", size: 15, mode: os.FileMode(420), modTime: time.Unix(1430781941, 0)}
|
info := bindataFileInfo{name: "in/b/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,8 +126,8 @@ func inCTestAsset() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "in/c/test.asset", size: 15, mode: os.FileMode(420), modTime: time.Unix(1430781941, 0)}
|
info := bindataFileInfo{name: "in/c/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,8 +146,8 @@ func inTestAsset() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "in/test.asset", size: 15, mode: os.FileMode(420), modTime: time.Unix(1430781941, 0)}
|
info := bindataFileInfo{name: "in/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ func Asset(name string) ([]byte, error) {
|
||||||
// It simplifies safe initialization of global variables.
|
// It simplifies safe initialization of global variables.
|
||||||
func MustAsset(name string) []byte {
|
func MustAsset(name string) []byte {
|
||||||
a, err := Asset(name)
|
a, err := Asset(name)
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
panic("asset: Asset(" + name + "): " + err.Error())
|
panic("asset: Asset(" + name + "): " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,72 +245,68 @@ func AssetDir(name string) ([]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type bintree struct {
|
type bintree struct {
|
||||||
Func func() (*asset, error)
|
Func func() (*asset, error)
|
||||||
Children map[string]*bintree
|
Children map[string]*bintree
|
||||||
}
|
}
|
||||||
var _bintree = &bintree{nil, map[string]*bintree{
|
var _bintree = &bintree{nil, map[string]*bintree{
|
||||||
"in": &bintree{nil, map[string]*bintree{
|
"in": &bintree{nil, map[string]*bintree{
|
||||||
"a": &bintree{nil, map[string]*bintree{
|
"a": &bintree{nil, map[string]*bintree{
|
||||||
"test.asset": &bintree{inATestAsset, map[string]*bintree{
|
"test.asset": &bintree{inATestAsset, map[string]*bintree{}},
|
||||||
}},
|
|
||||||
}},
|
}},
|
||||||
"b": &bintree{nil, map[string]*bintree{
|
"b": &bintree{nil, map[string]*bintree{
|
||||||
"test.asset": &bintree{inBTestAsset, map[string]*bintree{
|
"test.asset": &bintree{inBTestAsset, map[string]*bintree{}},
|
||||||
}},
|
|
||||||
}},
|
}},
|
||||||
"c": &bintree{nil, map[string]*bintree{
|
"c": &bintree{nil, map[string]*bintree{
|
||||||
"test.asset": &bintree{inCTestAsset, map[string]*bintree{
|
"test.asset": &bintree{inCTestAsset, map[string]*bintree{}},
|
||||||
}},
|
|
||||||
}},
|
|
||||||
"test.asset": &bintree{inTestAsset, map[string]*bintree{
|
|
||||||
}},
|
}},
|
||||||
|
"test.asset": &bintree{inTestAsset, map[string]*bintree{}},
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
|
|
||||||
// RestoreAsset restores an asset under the given directory
|
// RestoreAsset restores an asset under the given directory
|
||||||
func RestoreAsset(dir, name string) error {
|
func RestoreAsset(dir, name string) error {
|
||||||
data, err := Asset(name)
|
data, err := Asset(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
info, err := AssetInfo(name)
|
info, err := AssetInfo(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
|
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
|
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RestoreAssets restores an asset under the given directory recursively
|
// RestoreAssets restores an asset under the given directory recursively
|
||||||
func RestoreAssets(dir, name string) error {
|
func RestoreAssets(dir, name string) error {
|
||||||
children, err := AssetDir(name)
|
children, err := AssetDir(name)
|
||||||
// File
|
// File
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return RestoreAsset(dir, name)
|
return RestoreAsset(dir, name)
|
||||||
}
|
}
|
||||||
// Dir
|
// Dir
|
||||||
for _, child := range children {
|
for _, child := range children {
|
||||||
err = RestoreAssets(dir, filepath.Join(name, child))
|
err = RestoreAssets(dir, filepath.Join(name, child))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _filePath(dir, name string) string {
|
func _filePath(dir, name string) string {
|
||||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||||
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
98
testdata/out/debug.go
vendored
98
testdata/out/debug.go
vendored
|
@ -11,9 +11,9 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// bindataRead reads the given file from disk. It returns an error on failure.
|
// bindataRead reads the given file from disk. It returns an error on failure.
|
||||||
|
@ -32,7 +32,7 @@ type asset struct {
|
||||||
|
|
||||||
// inATestAsset reads file data from disk. It returns an error on failure.
|
// inATestAsset reads file data from disk. It returns an error on failure.
|
||||||
func inATestAsset() (*asset, error) {
|
func inATestAsset() (*asset, error) {
|
||||||
path := "/Users/tamird/src/go/src/github.com/jteeuwen/go-bindata/testdata/in/a/test.asset"
|
path := "/home/ts/code/go/src/github.com/jteeuwen/go-bindata/testdata/in/a/test.asset"
|
||||||
name := "in/a/test.asset"
|
name := "in/a/test.asset"
|
||||||
bytes, err := bindataRead(path, name)
|
bytes, err := bindataRead(path, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -50,7 +50,7 @@ func inATestAsset() (*asset, error) {
|
||||||
|
|
||||||
// inBTestAsset reads file data from disk. It returns an error on failure.
|
// inBTestAsset reads file data from disk. It returns an error on failure.
|
||||||
func inBTestAsset() (*asset, error) {
|
func inBTestAsset() (*asset, error) {
|
||||||
path := "/Users/tamird/src/go/src/github.com/jteeuwen/go-bindata/testdata/in/b/test.asset"
|
path := "/home/ts/code/go/src/github.com/jteeuwen/go-bindata/testdata/in/b/test.asset"
|
||||||
name := "in/b/test.asset"
|
name := "in/b/test.asset"
|
||||||
bytes, err := bindataRead(path, name)
|
bytes, err := bindataRead(path, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -68,7 +68,7 @@ func inBTestAsset() (*asset, error) {
|
||||||
|
|
||||||
// inCTestAsset reads file data from disk. It returns an error on failure.
|
// inCTestAsset reads file data from disk. It returns an error on failure.
|
||||||
func inCTestAsset() (*asset, error) {
|
func inCTestAsset() (*asset, error) {
|
||||||
path := "/Users/tamird/src/go/src/github.com/jteeuwen/go-bindata/testdata/in/c/test.asset"
|
path := "/home/ts/code/go/src/github.com/jteeuwen/go-bindata/testdata/in/c/test.asset"
|
||||||
name := "in/c/test.asset"
|
name := "in/c/test.asset"
|
||||||
bytes, err := bindataRead(path, name)
|
bytes, err := bindataRead(path, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -86,7 +86,7 @@ func inCTestAsset() (*asset, error) {
|
||||||
|
|
||||||
// inTestAsset reads file data from disk. It returns an error on failure.
|
// inTestAsset reads file data from disk. It returns an error on failure.
|
||||||
func inTestAsset() (*asset, error) {
|
func inTestAsset() (*asset, error) {
|
||||||
path := "/Users/tamird/src/go/src/github.com/jteeuwen/go-bindata/testdata/in/test.asset"
|
path := "/home/ts/code/go/src/github.com/jteeuwen/go-bindata/testdata/in/test.asset"
|
||||||
name := "in/test.asset"
|
name := "in/test.asset"
|
||||||
bytes, err := bindataRead(path, name)
|
bytes, err := bindataRead(path, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -121,7 +121,7 @@ func Asset(name string) ([]byte, error) {
|
||||||
// It simplifies safe initialization of global variables.
|
// It simplifies safe initialization of global variables.
|
||||||
func MustAsset(name string) []byte {
|
func MustAsset(name string) []byte {
|
||||||
a, err := Asset(name)
|
a, err := Asset(name)
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
panic("asset: Asset(" + name + "): " + err.Error())
|
panic("asset: Asset(" + name + "): " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,72 +196,68 @@ func AssetDir(name string) ([]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type bintree struct {
|
type bintree struct {
|
||||||
Func func() (*asset, error)
|
Func func() (*asset, error)
|
||||||
Children map[string]*bintree
|
Children map[string]*bintree
|
||||||
}
|
}
|
||||||
var _bintree = &bintree{nil, map[string]*bintree{
|
var _bintree = &bintree{nil, map[string]*bintree{
|
||||||
"in": &bintree{nil, map[string]*bintree{
|
"in": &bintree{nil, map[string]*bintree{
|
||||||
"a": &bintree{nil, map[string]*bintree{
|
"a": &bintree{nil, map[string]*bintree{
|
||||||
"test.asset": &bintree{inATestAsset, map[string]*bintree{
|
"test.asset": &bintree{inATestAsset, map[string]*bintree{}},
|
||||||
}},
|
|
||||||
}},
|
}},
|
||||||
"b": &bintree{nil, map[string]*bintree{
|
"b": &bintree{nil, map[string]*bintree{
|
||||||
"test.asset": &bintree{inBTestAsset, map[string]*bintree{
|
"test.asset": &bintree{inBTestAsset, map[string]*bintree{}},
|
||||||
}},
|
|
||||||
}},
|
}},
|
||||||
"c": &bintree{nil, map[string]*bintree{
|
"c": &bintree{nil, map[string]*bintree{
|
||||||
"test.asset": &bintree{inCTestAsset, map[string]*bintree{
|
"test.asset": &bintree{inCTestAsset, map[string]*bintree{}},
|
||||||
}},
|
|
||||||
}},
|
|
||||||
"test.asset": &bintree{inTestAsset, map[string]*bintree{
|
|
||||||
}},
|
}},
|
||||||
|
"test.asset": &bintree{inTestAsset, map[string]*bintree{}},
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
|
|
||||||
// RestoreAsset restores an asset under the given directory
|
// RestoreAsset restores an asset under the given directory
|
||||||
func RestoreAsset(dir, name string) error {
|
func RestoreAsset(dir, name string) error {
|
||||||
data, err := Asset(name)
|
data, err := Asset(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
info, err := AssetInfo(name)
|
info, err := AssetInfo(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
|
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
|
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RestoreAssets restores an asset under the given directory recursively
|
// RestoreAssets restores an asset under the given directory recursively
|
||||||
func RestoreAssets(dir, name string) error {
|
func RestoreAssets(dir, name string) error {
|
||||||
children, err := AssetDir(name)
|
children, err := AssetDir(name)
|
||||||
// File
|
// File
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return RestoreAsset(dir, name)
|
return RestoreAsset(dir, name)
|
||||||
}
|
}
|
||||||
// Dir
|
// Dir
|
||||||
for _, child := range children {
|
for _, child := range children {
|
||||||
err = RestoreAssets(dir, filepath.Join(name, child))
|
err = RestoreAssets(dir, filepath.Join(name, child))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _filePath(dir, name string) string {
|
func _filePath(dir, name string) string {
|
||||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||||
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
116
testdata/out/nocompress-memcopy.go
vendored
116
testdata/out/nocompress-memcopy.go
vendored
|
@ -10,11 +10,11 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"os"
|
|
||||||
"time"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
type asset struct {
|
type asset struct {
|
||||||
bytes []byte
|
bytes []byte
|
||||||
|
@ -22,9 +22,9 @@ type asset struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type bindataFileInfo struct {
|
type bindataFileInfo struct {
|
||||||
name string
|
name string
|
||||||
size int64
|
size int64
|
||||||
mode os.FileMode
|
mode os.FileMode
|
||||||
modTime time.Time
|
modTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,8 +60,8 @@ func inATestAsset() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "in/a/test.asset", size: 15, mode: os.FileMode(420), modTime: time.Unix(1431385279, 0)}
|
info := bindataFileInfo{name: "in/a/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,8 +78,8 @@ func inBTestAsset() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "in/b/test.asset", size: 15, mode: os.FileMode(420), modTime: time.Unix(1430781941, 0)}
|
info := bindataFileInfo{name: "in/b/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +96,8 @@ func inCTestAsset() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "in/c/test.asset", size: 15, mode: os.FileMode(420), modTime: time.Unix(1430781941, 0)}
|
info := bindataFileInfo{name: "in/c/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,8 +114,8 @@ func inTestAsset() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "in/test.asset", size: 15, mode: os.FileMode(420), modTime: time.Unix(1430781941, 0)}
|
info := bindataFileInfo{name: "in/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ func Asset(name string) ([]byte, error) {
|
||||||
// It simplifies safe initialization of global variables.
|
// It simplifies safe initialization of global variables.
|
||||||
func MustAsset(name string) []byte {
|
func MustAsset(name string) []byte {
|
||||||
a, err := Asset(name)
|
a, err := Asset(name)
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
panic("asset: Asset(" + name + "): " + err.Error())
|
panic("asset: Asset(" + name + "): " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,72 +213,68 @@ func AssetDir(name string) ([]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type bintree struct {
|
type bintree struct {
|
||||||
Func func() (*asset, error)
|
Func func() (*asset, error)
|
||||||
Children map[string]*bintree
|
Children map[string]*bintree
|
||||||
}
|
}
|
||||||
var _bintree = &bintree{nil, map[string]*bintree{
|
var _bintree = &bintree{nil, map[string]*bintree{
|
||||||
"in": &bintree{nil, map[string]*bintree{
|
"in": &bintree{nil, map[string]*bintree{
|
||||||
"a": &bintree{nil, map[string]*bintree{
|
"a": &bintree{nil, map[string]*bintree{
|
||||||
"test.asset": &bintree{inATestAsset, map[string]*bintree{
|
"test.asset": &bintree{inATestAsset, map[string]*bintree{}},
|
||||||
}},
|
|
||||||
}},
|
}},
|
||||||
"b": &bintree{nil, map[string]*bintree{
|
"b": &bintree{nil, map[string]*bintree{
|
||||||
"test.asset": &bintree{inBTestAsset, map[string]*bintree{
|
"test.asset": &bintree{inBTestAsset, map[string]*bintree{}},
|
||||||
}},
|
|
||||||
}},
|
}},
|
||||||
"c": &bintree{nil, map[string]*bintree{
|
"c": &bintree{nil, map[string]*bintree{
|
||||||
"test.asset": &bintree{inCTestAsset, map[string]*bintree{
|
"test.asset": &bintree{inCTestAsset, map[string]*bintree{}},
|
||||||
}},
|
|
||||||
}},
|
|
||||||
"test.asset": &bintree{inTestAsset, map[string]*bintree{
|
|
||||||
}},
|
}},
|
||||||
|
"test.asset": &bintree{inTestAsset, map[string]*bintree{}},
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
|
|
||||||
// RestoreAsset restores an asset under the given directory
|
// RestoreAsset restores an asset under the given directory
|
||||||
func RestoreAsset(dir, name string) error {
|
func RestoreAsset(dir, name string) error {
|
||||||
data, err := Asset(name)
|
data, err := Asset(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
info, err := AssetInfo(name)
|
info, err := AssetInfo(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
|
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
|
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RestoreAssets restores an asset under the given directory recursively
|
// RestoreAssets restores an asset under the given directory recursively
|
||||||
func RestoreAssets(dir, name string) error {
|
func RestoreAssets(dir, name string) error {
|
||||||
children, err := AssetDir(name)
|
children, err := AssetDir(name)
|
||||||
// File
|
// File
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return RestoreAsset(dir, name)
|
return RestoreAsset(dir, name)
|
||||||
}
|
}
|
||||||
// Dir
|
// Dir
|
||||||
for _, child := range children {
|
for _, child := range children {
|
||||||
err = RestoreAssets(dir, filepath.Join(name, child))
|
err = RestoreAssets(dir, filepath.Join(name, child))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _filePath(dir, name string) string {
|
func _filePath(dir, name string) string {
|
||||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||||
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
118
testdata/out/nocompress-nomemcopy.go
vendored
118
testdata/out/nocompress-nomemcopy.go
vendored
|
@ -10,13 +10,13 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"unsafe"
|
|
||||||
"os"
|
|
||||||
"time"
|
"time"
|
||||||
"io/ioutil"
|
"unsafe"
|
||||||
"path/filepath"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func bindataRead(data, name string) ([]byte, error) {
|
func bindataRead(data, name string) ([]byte, error) {
|
||||||
|
@ -36,9 +36,9 @@ type asset struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type bindataFileInfo struct {
|
type bindataFileInfo struct {
|
||||||
name string
|
name string
|
||||||
size int64
|
size int64
|
||||||
mode os.FileMode
|
mode os.FileMode
|
||||||
modTime time.Time
|
modTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ func inATestAsset() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "in/a/test.asset", size: 15, mode: os.FileMode(420), modTime: time.Unix(1431385279, 0)}
|
info := bindataFileInfo{name: "in/a/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +96,8 @@ func inBTestAsset() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "in/b/test.asset", size: 15, mode: os.FileMode(420), modTime: time.Unix(1430781941, 0)}
|
info := bindataFileInfo{name: "in/b/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,8 +116,8 @@ func inCTestAsset() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "in/c/test.asset", size: 15, mode: os.FileMode(420), modTime: time.Unix(1430781941, 0)}
|
info := bindataFileInfo{name: "in/c/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,8 +136,8 @@ func inTestAsset() (*asset, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "in/test.asset", size: 15, mode: os.FileMode(420), modTime: time.Unix(1430781941, 0)}
|
info := bindataFileInfo{name: "in/test.asset", size: 15, mode: os.FileMode(436), modTime: time.Unix(1445582844, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ func Asset(name string) ([]byte, error) {
|
||||||
// It simplifies safe initialization of global variables.
|
// It simplifies safe initialization of global variables.
|
||||||
func MustAsset(name string) []byte {
|
func MustAsset(name string) []byte {
|
||||||
a, err := Asset(name)
|
a, err := Asset(name)
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
panic("asset: Asset(" + name + "): " + err.Error())
|
panic("asset: Asset(" + name + "): " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,72 +235,68 @@ func AssetDir(name string) ([]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type bintree struct {
|
type bintree struct {
|
||||||
Func func() (*asset, error)
|
Func func() (*asset, error)
|
||||||
Children map[string]*bintree
|
Children map[string]*bintree
|
||||||
}
|
}
|
||||||
var _bintree = &bintree{nil, map[string]*bintree{
|
var _bintree = &bintree{nil, map[string]*bintree{
|
||||||
"in": &bintree{nil, map[string]*bintree{
|
"in": &bintree{nil, map[string]*bintree{
|
||||||
"a": &bintree{nil, map[string]*bintree{
|
"a": &bintree{nil, map[string]*bintree{
|
||||||
"test.asset": &bintree{inATestAsset, map[string]*bintree{
|
"test.asset": &bintree{inATestAsset, map[string]*bintree{}},
|
||||||
}},
|
|
||||||
}},
|
}},
|
||||||
"b": &bintree{nil, map[string]*bintree{
|
"b": &bintree{nil, map[string]*bintree{
|
||||||
"test.asset": &bintree{inBTestAsset, map[string]*bintree{
|
"test.asset": &bintree{inBTestAsset, map[string]*bintree{}},
|
||||||
}},
|
|
||||||
}},
|
}},
|
||||||
"c": &bintree{nil, map[string]*bintree{
|
"c": &bintree{nil, map[string]*bintree{
|
||||||
"test.asset": &bintree{inCTestAsset, map[string]*bintree{
|
"test.asset": &bintree{inCTestAsset, map[string]*bintree{}},
|
||||||
}},
|
|
||||||
}},
|
|
||||||
"test.asset": &bintree{inTestAsset, map[string]*bintree{
|
|
||||||
}},
|
}},
|
||||||
|
"test.asset": &bintree{inTestAsset, map[string]*bintree{}},
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
|
|
||||||
// RestoreAsset restores an asset under the given directory
|
// RestoreAsset restores an asset under the given directory
|
||||||
func RestoreAsset(dir, name string) error {
|
func RestoreAsset(dir, name string) error {
|
||||||
data, err := Asset(name)
|
data, err := Asset(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
info, err := AssetInfo(name)
|
info, err := AssetInfo(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
|
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
|
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RestoreAssets restores an asset under the given directory recursively
|
// RestoreAssets restores an asset under the given directory recursively
|
||||||
func RestoreAssets(dir, name string) error {
|
func RestoreAssets(dir, name string) error {
|
||||||
children, err := AssetDir(name)
|
children, err := AssetDir(name)
|
||||||
// File
|
// File
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return RestoreAsset(dir, name)
|
return RestoreAsset(dir, name)
|
||||||
}
|
}
|
||||||
// Dir
|
// Dir
|
||||||
for _, child := range children {
|
for _, child := range children {
|
||||||
err = RestoreAssets(dir, filepath.Join(name, child))
|
err = RestoreAssets(dir, filepath.Join(name, child))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _filePath(dir, name string) string {
|
func _filePath(dir, name string) string {
|
||||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||||
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
37
toc.go
37
toc.go
|
@ -53,23 +53,28 @@ func (root *assetTree) funcOrNil() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (root *assetTree) writeGoMap(w io.Writer, nident int) {
|
func (root *assetTree) writeGoMap(w io.Writer, nident int) {
|
||||||
fmt.Fprintf(w, "&bintree{%s, map[string]*bintree{\n", root.funcOrNil())
|
fmt.Fprintf(w, "&bintree{%s, map[string]*bintree{", root.funcOrNil())
|
||||||
|
|
||||||
// Sort to make output stable between invocations
|
if len(root.Children) > 0 {
|
||||||
filenames := make([]string, len(root.Children))
|
io.WriteString(w, "\n")
|
||||||
i := 0
|
|
||||||
for filename, _ := range root.Children {
|
|
||||||
filenames[i] = filename
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
sort.Strings(filenames)
|
|
||||||
|
|
||||||
for _, p := range filenames {
|
// Sort to make output stable between invocations
|
||||||
ident(w, nident+1)
|
filenames := make([]string, len(root.Children))
|
||||||
fmt.Fprintf(w, `"%s": `, p)
|
i := 0
|
||||||
root.Children[p].writeGoMap(w, nident+1)
|
for filename, _ := range root.Children {
|
||||||
|
filenames[i] = filename
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
sort.Strings(filenames)
|
||||||
|
|
||||||
|
for _, p := range filenames {
|
||||||
|
ident(w, nident+1)
|
||||||
|
fmt.Fprintf(w, `"%s": `, p)
|
||||||
|
root.Children[p].writeGoMap(w, nident+1)
|
||||||
|
}
|
||||||
|
ident(w, nident)
|
||||||
}
|
}
|
||||||
ident(w, nident)
|
|
||||||
io.WriteString(w, "}}")
|
io.WriteString(w, "}}")
|
||||||
if nident > 0 {
|
if nident > 0 {
|
||||||
io.WriteString(w, ",")
|
io.WriteString(w, ",")
|
||||||
|
@ -79,7 +84,7 @@ func (root *assetTree) writeGoMap(w io.Writer, nident int) {
|
||||||
|
|
||||||
func (root *assetTree) WriteAsGoMap(w io.Writer) error {
|
func (root *assetTree) WriteAsGoMap(w io.Writer) error {
|
||||||
_, err := fmt.Fprint(w, `type bintree struct {
|
_, err := fmt.Fprint(w, `type bintree struct {
|
||||||
Func func() (*asset, error)
|
Func func() (*asset, error)
|
||||||
Children map[string]*bintree
|
Children map[string]*bintree
|
||||||
}
|
}
|
||||||
var _bintree = `)
|
var _bintree = `)
|
||||||
|
@ -173,7 +178,7 @@ func Asset(name string) ([]byte, error) {
|
||||||
// It simplifies safe initialization of global variables.
|
// It simplifies safe initialization of global variables.
|
||||||
func MustAsset(name string) []byte {
|
func MustAsset(name string) []byte {
|
||||||
a, err := Asset(name)
|
a, err := Asset(name)
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
panic("asset: Asset(" + name + "): " + err.Error())
|
panic("asset: Asset(" + name + "): " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user