Fix go format of generated code

The following changes make the generated code go fmt compatible.
This commit is contained in:
Tobias Schmidt 2015-10-23 03:06:06 -04:00
parent bfe36d3254
commit 8ed2cd0f6d
9 changed files with 347 additions and 362 deletions

View File

@ -32,9 +32,9 @@ func writeDebugHeader(w io.Writer) error {
_, err := fmt.Fprintf(w, `import (
"fmt"
"io/ioutil"
"strings"
"os"
"path/filepath"
"strings"
)
// bindataRead reads the given file from disk. It returns an error on failure.

View File

@ -103,11 +103,11 @@ func header_compressed_nomemcopy(w io.Writer) error {
"compress/gzip"
"fmt"
"io"
"strings"
"os"
"time"
"io/ioutil"
"os"
"path/filepath"
"strings"
"time"
)
func bindataRead(data, name string) ([]byte, error) {
@ -140,11 +140,11 @@ func header_compressed_memcopy(w io.Writer) error {
"compress/gzip"
"fmt"
"io"
"strings"
"os"
"time"
"io/ioutil"
"os"
"path/filepath"
"strings"
"time"
)
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 {
_, err := fmt.Fprintf(w, `import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"strings"
"unsafe"
"os"
"time"
"io/ioutil"
"path/filepath"
"unsafe"
)
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 {
_, err := fmt.Fprintf(w, `import (
"fmt"
"strings"
"os"
"time"
"io/ioutil"
"os"
"path/filepath"
"strings"
"time"
)
`)
return err

View File

@ -13,11 +13,11 @@ import (
"compress/gzip"
"fmt"
"io"
"strings"
"os"
"time"
"io/ioutil"
"os"
"path/filepath"
"strings"
"time"
)
func bindataRead(data []byte, name string) ([]byte, error) {
@ -86,7 +86,7 @@ func inATestAsset() (*asset, error) {
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}
return a, nil
}
@ -106,7 +106,7 @@ func inBTestAsset() (*asset, error) {
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}
return a, nil
}
@ -126,7 +126,7 @@ func inCTestAsset() (*asset, error) {
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}
return a, nil
}
@ -146,7 +146,7 @@ func inTestAsset() (*asset, error) {
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}
return a, nil
}
@ -170,7 +170,7 @@ func Asset(name string) ([]byte, error) {
// It simplifies safe initialization of global variables.
func MustAsset(name string) []byte {
a, err := Asset(name)
if (err != nil) {
if err != nil {
panic("asset: Asset(" + name + "): " + err.Error())
}
@ -251,19 +251,15 @@ type bintree struct {
var _bintree = &bintree{nil, map[string]*bintree{
"in": &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{
"test.asset": &bintree{inBTestAsset, map[string]*bintree{
}},
"test.asset": &bintree{inBTestAsset, map[string]*bintree{}},
}},
"c": &bintree{nil, map[string]*bintree{
"test.asset": &bintree{inCTestAsset, map[string]*bintree{
}},
}},
"test.asset": &bintree{inTestAsset, map[string]*bintree{
"test.asset": &bintree{inCTestAsset, map[string]*bintree{}},
}},
"test.asset": &bintree{inTestAsset, map[string]*bintree{}},
}},
}}

View File

@ -13,11 +13,11 @@ import (
"compress/gzip"
"fmt"
"io"
"strings"
"os"
"time"
"io/ioutil"
"os"
"path/filepath"
"strings"
"time"
)
func bindataRead(data, name string) ([]byte, error) {
@ -86,7 +86,7 @@ func inATestAsset() (*asset, error) {
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}
return a, nil
}
@ -106,7 +106,7 @@ func inBTestAsset() (*asset, error) {
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}
return a, nil
}
@ -126,7 +126,7 @@ func inCTestAsset() (*asset, error) {
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}
return a, nil
}
@ -146,7 +146,7 @@ func inTestAsset() (*asset, error) {
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}
return a, nil
}
@ -170,7 +170,7 @@ func Asset(name string) ([]byte, error) {
// It simplifies safe initialization of global variables.
func MustAsset(name string) []byte {
a, err := Asset(name)
if (err != nil) {
if err != nil {
panic("asset: Asset(" + name + "): " + err.Error())
}
@ -251,19 +251,15 @@ type bintree struct {
var _bintree = &bintree{nil, map[string]*bintree{
"in": &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{
"test.asset": &bintree{inBTestAsset, map[string]*bintree{
}},
"test.asset": &bintree{inBTestAsset, map[string]*bintree{}},
}},
"c": &bintree{nil, map[string]*bintree{
"test.asset": &bintree{inCTestAsset, map[string]*bintree{
}},
}},
"test.asset": &bintree{inTestAsset, map[string]*bintree{
"test.asset": &bintree{inCTestAsset, map[string]*bintree{}},
}},
"test.asset": &bintree{inTestAsset, map[string]*bintree{}},
}},
}}

24
testdata/out/debug.go vendored
View File

@ -11,9 +11,9 @@ package main
import (
"fmt"
"io/ioutil"
"strings"
"os"
"path/filepath"
"strings"
)
// 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.
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"
bytes, err := bindataRead(path, name)
if err != nil {
@ -50,7 +50,7 @@ func inATestAsset() (*asset, error) {
// inBTestAsset reads file data from disk. It returns an error on failure.
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"
bytes, err := bindataRead(path, name)
if err != nil {
@ -68,7 +68,7 @@ func inBTestAsset() (*asset, error) {
// inCTestAsset reads file data from disk. It returns an error on failure.
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"
bytes, err := bindataRead(path, name)
if err != nil {
@ -86,7 +86,7 @@ func inCTestAsset() (*asset, error) {
// inTestAsset reads file data from disk. It returns an error on failure.
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"
bytes, err := bindataRead(path, name)
if err != nil {
@ -121,7 +121,7 @@ func Asset(name string) ([]byte, error) {
// It simplifies safe initialization of global variables.
func MustAsset(name string) []byte {
a, err := Asset(name)
if (err != nil) {
if err != nil {
panic("asset: Asset(" + name + "): " + err.Error())
}
@ -202,19 +202,15 @@ type bintree struct {
var _bintree = &bintree{nil, map[string]*bintree{
"in": &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{
"test.asset": &bintree{inBTestAsset, map[string]*bintree{
}},
"test.asset": &bintree{inBTestAsset, map[string]*bintree{}},
}},
"c": &bintree{nil, map[string]*bintree{
"test.asset": &bintree{inCTestAsset, map[string]*bintree{
}},
}},
"test.asset": &bintree{inTestAsset, map[string]*bintree{
"test.asset": &bintree{inCTestAsset, map[string]*bintree{}},
}},
"test.asset": &bintree{inTestAsset, map[string]*bintree{}},
}},
}}

View File

@ -10,11 +10,11 @@ package main
import (
"fmt"
"strings"
"os"
"time"
"io/ioutil"
"os"
"path/filepath"
"strings"
"time"
)
type asset struct {
bytes []byte
@ -60,7 +60,7 @@ func inATestAsset() (*asset, error) {
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}
return a, nil
}
@ -78,7 +78,7 @@ func inBTestAsset() (*asset, error) {
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}
return a, nil
}
@ -96,7 +96,7 @@ func inCTestAsset() (*asset, error) {
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}
return a, nil
}
@ -114,7 +114,7 @@ func inTestAsset() (*asset, error) {
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}
return a, nil
}
@ -138,7 +138,7 @@ func Asset(name string) ([]byte, error) {
// It simplifies safe initialization of global variables.
func MustAsset(name string) []byte {
a, err := Asset(name)
if (err != nil) {
if err != nil {
panic("asset: Asset(" + name + "): " + err.Error())
}
@ -219,19 +219,15 @@ type bintree struct {
var _bintree = &bintree{nil, map[string]*bintree{
"in": &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{
"test.asset": &bintree{inBTestAsset, map[string]*bintree{
}},
"test.asset": &bintree{inBTestAsset, map[string]*bintree{}},
}},
"c": &bintree{nil, map[string]*bintree{
"test.asset": &bintree{inCTestAsset, map[string]*bintree{
}},
}},
"test.asset": &bintree{inTestAsset, map[string]*bintree{
"test.asset": &bintree{inCTestAsset, map[string]*bintree{}},
}},
"test.asset": &bintree{inTestAsset, map[string]*bintree{}},
}},
}}

View File

@ -10,13 +10,13 @@ package main
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"strings"
"unsafe"
"os"
"time"
"io/ioutil"
"path/filepath"
"unsafe"
)
func bindataRead(data, name string) ([]byte, error) {
@ -76,7 +76,7 @@ func inATestAsset() (*asset, error) {
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}
return a, nil
}
@ -96,7 +96,7 @@ func inBTestAsset() (*asset, error) {
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}
return a, nil
}
@ -116,7 +116,7 @@ func inCTestAsset() (*asset, error) {
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}
return a, nil
}
@ -136,7 +136,7 @@ func inTestAsset() (*asset, error) {
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}
return a, nil
}
@ -160,7 +160,7 @@ func Asset(name string) ([]byte, error) {
// It simplifies safe initialization of global variables.
func MustAsset(name string) []byte {
a, err := Asset(name)
if (err != nil) {
if err != nil {
panic("asset: Asset(" + name + "): " + err.Error())
}
@ -241,19 +241,15 @@ type bintree struct {
var _bintree = &bintree{nil, map[string]*bintree{
"in": &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{
"test.asset": &bintree{inBTestAsset, map[string]*bintree{
}},
"test.asset": &bintree{inBTestAsset, map[string]*bintree{}},
}},
"c": &bintree{nil, map[string]*bintree{
"test.asset": &bintree{inCTestAsset, map[string]*bintree{
}},
}},
"test.asset": &bintree{inTestAsset, map[string]*bintree{
"test.asset": &bintree{inCTestAsset, map[string]*bintree{}},
}},
"test.asset": &bintree{inTestAsset, map[string]*bintree{}},
}},
}}

9
toc.go
View File

@ -53,7 +53,10 @@ func (root *assetTree) funcOrNil() string {
}
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())
if len(root.Children) > 0 {
io.WriteString(w, "\n")
// Sort to make output stable between invocations
filenames := make([]string, len(root.Children))
@ -70,6 +73,8 @@ func (root *assetTree) writeGoMap(w io.Writer, nident int) {
root.Children[p].writeGoMap(w, nident+1)
}
ident(w, nident)
}
io.WriteString(w, "}}")
if nident > 0 {
io.WriteString(w, ",")
@ -173,7 +178,7 @@ func Asset(name string) ([]byte, error) {
// It simplifies safe initialization of global variables.
func MustAsset(name string) []byte {
a, err := Asset(name)
if (err != nil) {
if err != nil {
panic("asset: Asset(" + name + "): " + err.Error())
}