maddyblue / esc

A simple file embedder for Go
http://godoc.org/github.com/mjibson/esc
MIT License
637 stars 73 forks source link

Added example to README to demonstrate FS() usage with http.FileServer #7

Closed warmans closed 9 years ago

warmans commented 9 years ago

I like this library but I would have found it easier to get started with an example such as this.

maddyblue commented 9 years ago

I'd prefer if this were added to doc.go instead. But yes! I've wanted to do this myself because I forget exactly how it works unless I can see some code.

warmans commented 9 years ago

Sure. I've moved the example to the godoc. I think my editor has tried to standardize the whitespace. If this is an issue I can change them back to tabs.

maddyblue commented 9 years ago

I think a more concrete example is needed:

1) create main.go as described 2) run esc -o static.go main.go, which will embed main.go into static.go 3) run it 4) hit http://localhost:8080/main.go

This will also require changing the handler path to just /.

Or maybe this is too weird and not useful since it doesn't include a directory, which is the expected case?

maddyblue commented 9 years ago

And yes, please fix the whitespace to tabs.

warmans commented 9 years ago

I've tried to clarify the process as per 1/2/3/4. I think just embedding main.go slightly obscures the common use of the library as I believe most people would have their static assets in a sub-directory. Admittedly the upside is that it does allow the example to run without creating random directories.

maddyblue commented 9 years ago

Thanks.