Git Product home page Git Product logo

Comments (7)

slimsag avatar slimsag commented on July 19, 2024

You can already, but thet will have to be in separate (sub) packages which
is nicer anyway IMO)
On Jul 5, 2015 2:22 PM, "Tim Hughes" [email protected] wrote:

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


Reply to this email directly or view it on GitHub
#20.

from go-bindata-assetfs.

markwallsgrove avatar markwallsgrove commented on July 19, 2024

@timhughes when using go-bindata-assetfs and/or go-bindata use the -pkg flag to achieve what @slimsag suggested.

go-bindata-assetfs -o static_bindata.go -pkg static static/... 
go-bindata -o template_bindata.go -pkg templates templates/...
go build

from go-bindata-assetfs.

xiaods avatar xiaods commented on July 19, 2024

cool

from go-bindata-assetfs.

jbowens avatar jbowens commented on July 19, 2024

Why does go-bindata-assetfs require it's own command? Can you not implement http.FIleSystem through the go-bindata table of contents?

from go-bindata-assetfs.

elazarl avatar elazarl commented on July 19, 2024

@jbowens this is to create the actual go files containing the data.

from go-bindata-assetfs.

jbowens avatar jbowens commented on July 19, 2024

@elazarl Right. My question is how it differs from go-bindata. AFAICT, go-bindata-assetfs doesn't generate any additional data beyond what go-bindata generates.

It seems to me you could use go-bindata to generate the the Go files with the data as normal, and then go-bindata-assetfs can expose a function like:

type BindataPkg struct {
    Asset     func(string) ([]byte, error)
    AssetInfo func(string) (os.FileInfo, error)
    AssetDir  func(name string) ([]string, error)
}

func FileSystem(bindata BindataPkg) http.FileSystem {
    // ...
}

Then instead of having to use a separate command for go-bindata-assetfs, users can generate Go using go-bindata and within their application call:

fs := assetfs.FileSystem(BindataPkg{
    Asset:     myassetspkg.Asset,
    AssetInfo: myassetspkg.AssetInfo,
    AssetDir:  myassetspkg.AssetDir,
})
mux.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(fs)))

Why does go-bindata-assetfs need code generation beyond what go-bindata already provides?

from go-bindata-assetfs.

jbowens avatar jbowens commented on July 19, 2024

Ah, sorry, I see. That's literally what AssetFS is. The code generation tool is just intended for convenience?

from go-bindata-assetfs.

Related Issues (20)

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.