What does go list -f '{{ .EmbedFiles }}'
display? On Monday, 5 July 2021 at 06:28:54 UTC+1 tjgur...@gmail.com wrote: > Hi there, > > I have been testing the (relatively) new go:embed feature for a few days > and I came across this situation which I wasn't quite sure what was causing > it so I thought asking here would help. > > Consider the following code: > > ```golang > package main > > import ( > "embed" > "fmt" > "log" > "net/http" > ) > > //go:embed files/static > var static embed.FS > > func main() { > http.Handle("/static/", http.StripPrefix("/static/", > http.FileServer(http.FS(static)))) > log.Fatal(http.ListenAndServe(":8000", nil)) > } > > ``` > > Now the files in directory files/static are very much accessible but the > issue I seem to have is that it was accessible under the url > /static/files/static/filename instead of just being accessible through > /static/filename where filename exists inside the directory files/static/ > > I tried looking up some examples online and it seems that I have to use > the fs.FS and fs.Sub and only expose (not sure if this is correct > terminology) the new fs.Sub which would mitigate the issue I was having. > > My question is about the reason why the Go team went with this > implementation? Because in the above program I wasn't able to access the > files in files/ directory even though there were files in it and was only > able to access files inside the files/static files directory. So there > doesn't seem to be a point in this implementation unless I'm missing > something, and I'm sure its the latter case haha. If anyone knows about why > they went with this implementation, I would be very grateful. > > Best wishes > Taj > > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/5334f169-1623-4865-8f54-f33c4435ce36n%40googlegroups.com.