From b546045c44072330d945f18e99ec905a0cb82d08 Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Thu, 10 Sep 2015 16:59:19 -0400 Subject: [PATCH] bump(github.com/elazarl/go-bindata-assetfs): 3dcc96556217539f50599357fb481ac0dc7439b9 --- Godeps/Godeps.json | 2 +- .../elazarl/go-bindata-assetfs/assetfs.go | 8 ++-- .../go-bindata-assetfs/main.go | 41 +++++++++++++++++-- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 8e4a67f9562..16bb8ee8fae 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -211,7 +211,7 @@ }, { "ImportPath": "github.com/elazarl/go-bindata-assetfs", - "Rev": "c57a80f1ab2ad67bafa83f5fd0b4c2ecbd253dd5" + "Rev": "3dcc96556217539f50599357fb481ac0dc7439b9" }, { "ImportPath": "github.com/emicklei/go-restful", diff --git a/Godeps/_workspace/src/github.com/elazarl/go-bindata-assetfs/assetfs.go b/Godeps/_workspace/src/github.com/elazarl/go-bindata-assetfs/assetfs.go index 69d58f8c453..5174d5a6d3c 100644 --- a/Godeps/_workspace/src/github.com/elazarl/go-bindata-assetfs/assetfs.go +++ b/Godeps/_workspace/src/github.com/elazarl/go-bindata-assetfs/assetfs.go @@ -136,12 +136,12 @@ func (fs *AssetFS) Open(name string) (http.File, error) { if len(name) > 0 && name[0] == '/' { name = name[1:] } + if b, err := fs.Asset(name); err == nil { + return NewAssetFile(name, b), nil + } if children, err := fs.AssetDir(name); err == nil { return NewAssetDirectory(name, children, fs), nil - } - b, err := fs.Asset(name) - if err != nil { + } else { return nil, err } - return NewAssetFile(name, b), nil } diff --git a/Godeps/_workspace/src/github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs/main.go b/Godeps/_workspace/src/github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs/main.go index 86271aae14b..a5b2b5eef56 100644 --- a/Godeps/_workspace/src/github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs/main.go +++ b/Godeps/_workspace/src/github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs/main.go @@ -3,13 +3,31 @@ package main import ( "bufio" "bytes" + "flag" "fmt" "os" "os/exec" + "strings" ) const bindatafile = "bindata.go" +func isDebug(args []string) bool { + flagset := flag.NewFlagSet("", flag.ContinueOnError) + debug := flagset.Bool("debug", false, "") + debugArgs := make([]string, 0) + for _, arg := range args { + if strings.HasPrefix(arg, "-debug") { + debugArgs = append(debugArgs, arg) + } + } + flagset.Parse(debugArgs) + if debug == nil { + return false + } + return *debug +} + func main() { if _, err := exec.LookPath("go-bindata"); err != nil { fmt.Println("Cannot find go-bindata executable in path") @@ -33,26 +51,43 @@ func main() { fmt.Fprintln(os.Stderr, "Cannot write 'bindata_assetfs.go'", err) return } + debug := isDebug(os.Args[1:]) r := bufio.NewReader(in) done := false for line, isPrefix, err := r.ReadLine(); err == nil; line, isPrefix, err = r.ReadLine() { - line = append(line, '\n') + if !isPrefix { + line = append(line, '\n') + } if _, err := out.Write(line); err != nil { fmt.Fprintln(os.Stderr, "Cannot write to 'bindata_assetfs.go'", err) return } if !done && !isPrefix && bytes.HasPrefix(line, []byte("import (")) { - fmt.Fprintln(out, "\t\"github.com/elazarl/go-bindata-assetfs\"") + if debug { + fmt.Fprintln(out, "\t\"net/http\"") + } else { + fmt.Fprintln(out, "\t\"github.com/elazarl/go-bindata-assetfs\"") + } done = true } } - fmt.Fprintln(out, ` + if debug { + fmt.Fprintln(out, ` +func assetFS() http.FileSystem { + for k := range _bintree.Children { + return http.Dir(k) + } + panic("unreachable") +}`) + } else { + fmt.Fprintln(out, ` func assetFS() *assetfs.AssetFS { for k := range _bintree.Children { return &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, Prefix: k} } panic("unreachable") }`) + } // Close files BEFORE remove calls (don't use defer). in.Close() out.Close()