You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This bug is kind of hilarious, so we have an html file template that we include in our bin with vfsgen in a package called assets, but because go generate puts the assets_vfsdata.go in the root directory, we move it into assets folder after it's generated. After repeating this process with the assets_vfsdata.go in there, the generated assets_vfsdata.go was ~1.8GB!! with no errors of any kind reported. Of course I changed the directory structure to prevent this, but I found it very interesting that this is possible without a stack overflow of some kind.
File system:
./assets/report-template.html
./assets/assets_vfsdata.go // after initial generation and copying from ./assets_vfsdata.go
`// +build ignore
package main
import (
"log"
"net/http"
"github.com/shurcooL/vfsgen"
)
func main() {
var fs http.FileSystem = http.Dir("./assets")
I switched to http.Dir("./assets/src")
and moved report-template.html into ./assets/src to fix this, but I was pretty surprised that it was even possible
The text was updated successfully, but these errors were encountered:
Thanks for sharing this scenario that you've encountered.
vfsgen is a simple tool that operates on whatever arbitrary input you provide it. I'm not sure if it's viable to detect that its own output is a part of the input, at least not in the general case.
Right now, I can't think of anything that can be done to improve the situation here. Let me know if you have suggestions.
This bug is kind of hilarious, so we have an html file template that we include in our bin with vfsgen in a package called assets, but because
go generate
puts the assets_vfsdata.go in the root directory, we move it into assets folder after it's generated. After repeating this process with the assets_vfsdata.go in there, the generated assets_vfsdata.go was ~1.8GB!! with no errors of any kind reported. Of course I changed the directory structure to prevent this, but I found it very interesting that this is possible without a stack overflow of some kind.File system:
./assets/report-template.html
./assets/assets_vfsdata.go // after initial generation and copying from ./assets_vfsdata.go
`// +build ignore
package main
import (
"log"
"net/http"
)
func main() {
var fs http.FileSystem = http.Dir("./assets")
}
`
I switched to
http.Dir("./assets/src")
and moved report-template.html into ./assets/src to fix this, but I was pretty surprised that it was even possible
The text was updated successfully, but these errors were encountered: