Giter Club home page Giter Club logo

go-bindata-assetfs's People

Contributors

aarono avatar dmitshur avatar elazarl avatar hheld avatar hillu avatar jjeffery avatar jkuri avatar joegasewicz avatar keegancsmith avatar khaos-one avatar korylprince avatar liggitt avatar mfindlater avatar petermattis avatar pwielgolaski avatar themihai avatar unrud avatar vcabbage avatar winwisely268 avatar xxzgc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-bindata-assetfs's Issues

ability to define default document

Among my assets I have a 404.html. I am finding it troublesome to get net/http to host that as the final 404. Since I am hosting the assetfs at "/", I can't figure out how to make it work.

What if I could define something like this:

http.Handle("/", http.FileServer( &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, Prefix: "data", DefaultDoc:"404.html"}))

I can submit a pull request if you like. What do you think?

Undefined type in generated file

I'm getting the following error in the generated file bindata_assetfs.go:
undefined: AssetInfo

This happens in this generated function:

func assetFS() *assetfs.AssetFS {
    for k := range _bintree.Children {
        return &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, AssetInfo: AssetInfo, Prefix: k}
    }
    panic("unreachable")
}

assetFS function only returns first folder

go-bindata-assetfs -pkg=bootstrap css fonts js

Only the css folder is returned.

func assetFS() *assetfs.AssetFS {
    for k := range _bintree.Children {
        return &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, Prefix: k}
    }
    panic("unreachable")
}

Broken by changes on Go tip/master

Any code described in the "Without running binary tool" section shows is broken by some changes on Go tip/master. The following program can reproduce the issue:

package main

import "github.com/elazarl/go-bindata-assetfs"

func main() {
        _ = http.FileServer(&assetfs.AssetFS{})
}

which produces:

# github.com/elazarl/go-bindata-assetfs
../assetfs.go:77: AssetFile.Size is ambiguous
../assetfs.go:77: cannot use f (type *AssetFile) as type os.FileInfo in return argument:
    *AssetFile does not implement os.FileInfo (missing Size method)
../assetfs.go:116: AssetDirectory.Size is ambiguous
../assetfs.go:116: cannot use f (type *AssetDirectory) as type os.FileInfo in return argument:
    *AssetDirectory does not implement os.FileInfo (missing Size method)

This is because AssetFile is defined as:

type AssetFile struct {
    *bytes.Reader
    io.Closer
    FakeFile
}

A Go commit in tip (golang/go@c264c87) added a Size method to *bytes.Reader, and since FakeFile also has a Size method -- it's ambiguous and thus breaks.

Error when building the project

/bindata_assetfs.go:9527: undefined: _bintree in _bintree.Children
./bindata_assetfs.go:9528: undefined: AssetDir
./bindata_assetfs.go:9528: undefined: AssetInfo

bindata_assefts fails with golint

I needed to use this library to embed my static files but when applying golint it fails due to functions containing underscores inside names etc.
It is a little boring replacing all those functions names for my static file with CameCase style.

I finished changing your convert.go, safeFunctionName function, replacing "_" with "". to remove _ from names.

Thanks.

Cannot declare multiple directories with `go-bindata-assetfs` or a single child.

Problem:
I want to declare multiple files when using the go-bindata-assetfs cmd:

$ go-bindata-assetfs dist/... public/...

OR I want to only specify the dist directory:

$ go-bindata-assetfs dist/...

But because the dist directory has a public directory sibling, the assetFS() will randomly pick either the dist or public directory to generate from.

Issue:
The call to assetFS() will randomly pass back only the first item in the _bintree.Children slices, which means that if I pass a top level directory with multiple children directories assetFS() will not return the desired results.

Requested changes:

I want to be able to define each static path to serve manually, either multiple of a single child directory. This example demonstrates serving 2 static directories but even if i just want to serve a single directory assetFS() will not work if there are more than 1 directories present:

func main() {
	r := mux.NewRouter() // Example uses "github.com/gorilla/mux"
    // Here we want to serve static content from 2 directories
	r.PathPrefix("/dist").Handler(http.StripPrefix("/dist", http.FileServer(AssetDIR("dist"))))
	r.PathPrefix("/public").Handler(http.StripPrefix("/public", http.FileServer(AssetDIR("public"))))
    // rest of server code...
	server := &http.Server{ Addr:    ":7777", Handler: r, }
	server.ListenAndServe()
}

some access error when use in windows

when I want use go-bindata in windows system,some error happens.D:\go\src\git.bwae.org\portal\cluster-admin>go-bindata-assetfs web\ui\... bindata: open web\ui\...: Access is denied. Error: go-bindata: exit status 1

linux is ok.

Feature Request: be able to use both go-bindata and go-bindata-assetfs at the same time

I would like to use go-bindata-assetfs for serving static assets such as javascript and css but then use go-bindata for my templates but when I do I get naming clashes. I also do not want to serve my templates using http.FileSystem . I think this use case will come up a lot when building tiny web apps.

go-bindata-assetfs -o static_bindata.go static/... 
go-bindata -o template_bindata.go templates/...
go build
Cannot read bindata.go open bindata.go: no such file or directory
# git.timhughes.org/timhughes/githook
./template_bindata.go:20: bindataRead redeclared in this block
    previous declaration at ./static_bindata.go:19
./template_bindata.go:40: asset redeclared in this block
    previous declaration at ./static_bindata.go:39
./template_bindata.go:45: bindataFileInfo redeclared in this block
    previous declaration at ./static_bindata.go:44
./template_bindata.go:52: bindataFileInfo.Name redeclared in this block
    previous declaration at ./static_bindata.go:51
./template_bindata.go:55: bindataFileInfo.Size redeclared in this block
    previous declaration at ./static_bindata.go:54
./template_bindata.go:58: bindataFileInfo.Mode redeclared in this block
    previous declaration at ./static_bindata.go:57
./template_bindata.go:61: bindataFileInfo.ModTime redeclared in this block
    previous declaration at ./static_bindata.go:60
./template_bindata.go:64: bindataFileInfo.IsDir redeclared in this block
    previous declaration at ./static_bindata.go:63
./template_bindata.go:67: bindataFileInfo.Sys redeclared in this block
    previous declaration at ./static_bindata.go:66
./template_bindata.go:94: Asset redeclared in this block
    previous declaration at ./static_bindata.go:73
./template_bindata.go:94: too many errors

does not handle -o properly

I am just getting started with your tool. Great job!

I noticed an error message when I use it for my assets:

$ go-bindata-assetfs -pkg gogrinder -o gogrinder/assetfs.go web/...
Cannot read bindata.go open bindata.go: no such file or directory

creates the asset file but this is section missing:

func assetFS() *assetfs.AssetFS {
    for k := range _bintree.Children {
        return &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, AssetInfo: AssetInfo, Prefix: k}
    }
    panic("unreachable")
}

Please tag and version this project

Tags and versions aid in packaging for things like .deb files, and for anyone wanting to use Glide and other version based package managers to version their dependencies. It would also help ensure that if you make a breaking change, we don't pull it down until we are ready.

Protecting users of obsolete API (pre AssetInfo)

I wonder if you would consider a change to AssetFS to protect others from a problem I had, and took quite a while for me to find the root cause?

I have a project that used your older API (without the AssetInfo field).

http.Handle("/",
http.FileServer(
&assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir}))

My project still compiled fine with the newer versions of AssetFS code despite what is now a missing initialiser, but hits a null pointer error at run time at line 148 in assetfs.go with this:

if info, err := fs.AssetInfo(name); err == nil {

All fine now I updated my call of course, but shame to require others who hit the same problem to dig into AssetFS source to work out what's happening.

Pete

Why FakeFile and not AssetInfo()'s os.FileInfo?

The problem that got me there: FakeFile's Modtime is the binary's startup time, which breaks all caching on restart and with multiple instances.

What's the reason for this? If you're ok with that, I'd make a pull request in the next days changing it to use AssetInfo().

Have a good one! :)

question / idea

this looks really nice.

i am thinking of a slightly different applicatin of this.
I think i can use this for packaging my own server deployment package too. Like when you need a stupid c lib on the server or client. i can pack it in, and then install it from a nice single deployed app.

the .sh bash install script can be embedded, but i expect a golang server on the server will need to call it, due to security issues.

does anyone else know a different way of approaching this ? Or maybe your interested in extending this project to do it, or make another project that uses this to do it.

Loaded assets from go-bindata via assetfs.AssetFS are empty

Hello

I'm stuck with an issue regarding go-bindata and unrolled/render. I uploaded a sample code for reproduction: https://github.com/hachi8833/myapp

I added a route for assets as suggested in unrolled/render#44, and looked fine at first. But actually the loaded assets (css, js) from go-bindata binary are all empty (except template) while HTTP status are successful with 200.

Note that template files under template/*.tmpl are loaded with github.com/unrolled/render.

I'm wondering if I misunderstand or overlook something and I'd be glad if you point out what is wrong with my code.

Best regards,

os package imported twice

A line from a PR that was merged yesterday is causing generated files to error because os is being imported twice, once by the addition of this line and once by the import that go_bindata generates.

osohno

I don't believe the os addition is necessary for any set of underlying options sent to go_bindata. It looks like all of the possible import headers it could write out all include os:

Gzip headers

It would be neat to check an HTTP request for Accept-Encoding: gzip to return assets with a Content-Encoding: gzip header and the compressed asset body.

Is there already a way to do this that I've missed?

Errors are not handled

The fileserver implementation returns http 200 regardless if the file exists or not or if there is any other error reading it.

assetFS.Prefix does not behave as expected

The Prefix property (and underlying code) does not behave as expected.

If one have data directory with two files, for example, app.html and index.html, overall Prefix property of assetFS becomes equal to the path of one of the files in the dir (for example, Prefix = data/app.html).

The Open() call (as seen from sources) just prepends Prefix field to the requested file name, which, considering the above, leads to unavailability of all packed files -- request to data/index.html is translated to data/app.html/data/index.html which is not quite correct.

If one is specifying the prefix explicitly with --prefix key the software acts exactly the same.

A dirty resolution to the issue is to completely omit Prefix field, then it works like a charm.

assetFS is not exportable

assetFS is not exportable. so i do :
go-bindata-assetfs -pkg res resources/..
then in generated bindata_assetfs.go i changing assetFS to AssetFS and using it like
import {...
"bindata_assetfs"
}
http.Handle("/resources", http.FileServer(res.AssetFS()))

Import order to pass linting

Hey it would be great if the import order followed the go style guide. The side effect of this is that projects that lint fail because of the generated code.

The imports should look like:

package agent

import (
    "bytes"
    "compress/gzip"
    "fmt"
    "io"
    "io/ioutil"
    "os"
    "path/filepath"
    "strings"
    "time"

    "github.com/elazarl/go-bindata-assetfs"
)

Tag/Release v1.0.1

On May 9th there was a PR that adds a fallback for Single page Applications. Right now the code is only in master, can you make a tag/release v1.0.1 so go.mod can reference directly to it and not master?

thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.