Skip to content

Commit

Permalink
Fix go format of generated code
Browse files Browse the repository at this point in the history
The following changes make the generated code go fmt compatible.
  • Loading branch information
grobie committed Oct 23, 2015
1 parent bfe36d3 commit 8ed2cd0
Show file tree
Hide file tree
Showing 9 changed files with 347 additions and 362 deletions.
2 changes: 1 addition & 1 deletion debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
34 changes: 17 additions & 17 deletions release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -218,9 +218,9 @@ func header_release_common(w io.Writer) error {
}
type bindataFileInfo struct {
name string
size int64
mode os.FileMode
name string
size int64
mode os.FileMode
modTime time.Time
}
Expand Down Expand Up @@ -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)}
a := &asset{bytes: bytes, info: info}
a := &asset{bytes: bytes, info: info}
return a, nil
}
Expand Down
72 changes: 36 additions & 36 deletions restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,49 @@ func writeRestore(w io.Writer) error {
_, err := fmt.Fprintf(w, `
// RestoreAsset restores an asset under the given directory
func RestoreAsset(dir, name string) error {
data, err := Asset(name)
if err != nil {
return err
}
info, err := AssetInfo(name)
if err != nil {
return err
}
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
if err != nil {
return err
}
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
if err != nil {
return err
}
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
if err != nil {
return err
}
return nil
data, err := Asset(name)
if err != nil {
return err
}
info, err := AssetInfo(name)
if err != nil {
return err
}
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
if err != nil {
return err
}
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
if err != nil {
return err
}
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
if err != nil {
return err
}
return nil
}
// RestoreAssets restores an asset under the given directory recursively
func RestoreAssets(dir, name string) error {
children, err := AssetDir(name)
// File
if err != nil {
return RestoreAsset(dir, name)
}
// Dir
for _, child := range children {
err = RestoreAssets(dir, filepath.Join(name, child))
if err != nil {
return err
}
}
return nil
children, err := AssetDir(name)
// File
if err != nil {
return RestoreAsset(dir, name)
}
// Dir
for _, child := range children {
err = RestoreAssets(dir, filepath.Join(name, child))
if err != nil {
return err
}
}
return nil
}
func _filePath(dir, name string) string {
cannonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
cannonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
}
`)
Expand Down
116 changes: 56 additions & 60 deletions testdata/out/compress-memcopy.go

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

Loading

0 comments on commit 8ed2cd0

Please sign in to comment.