DEV Community

Discussion on: The easiest way to embed static files into a binary file in your Golang app (no external dependencies)

Collapse
 
fguisso profile image
Fernando Guisso

my solution:

for filename, content := range static.Map() {                               
         r.HandleFunc(fmt.Sprintf("/static%v", filename),                        
             func(w http.ResponseWriter, r *http.Request) {                      
                 http.ServeContent(w, r, "test.txt", time.Now(),                 
                 bytes.NewReader(content))                                                                  
         })                                                                                                 
}
Enter fullscreen mode Exit fullscreen mode

static is my box pkg and the .Map just return the storages map

The problem now is because I use the html/template to generate some pages, and I can't use the funcs of this pkg :(