Comments (7)
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 buildCannot 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.
@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.
cool
from go-bindata-assetfs.
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.
@jbowens this is to create the actual go files containing the data.
from go-bindata-assetfs.
@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.
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)
- Gzip headers HOT 2
- bindata_assefts fails with golint HOT 1
- Loaded assets from go-bindata via assetfs.AssetFS are empty HOT 1
- Why FakeFile and not AssetInfo()'s os.FileInfo? HOT 2
- AssetInfo - runtime error: invalid memory address HOT 3
- binddata.go file cannot be found if output location is changed
- does not handle -o properly HOT 12
- Protecting users of obsolete API (pre AssetInfo)
- Please tag and version this project HOT 1
- Error when building the project
- Undefined type in generated file
- os package imported twice HOT 3
- Impossible to use theres no Assetfs function exported from the produced go code HOT 2
- assetFS is not exportable HOT 3
- Can I manage file in AssetFS?
- Import order to pass linting HOT 3
- some access error when use in windows HOT 2
- Tag/Release v1.0.1 HOT 2
- Cannot declare multiple directories with `go-bindata-assetfs` or a single child.
- go get is deprecated in go version 1.17 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-bindata-assetfs.