1
0

main.go 491 B

12345678910111213141516171819202122
  1. package main
  2. import (
  3. "log"
  4. "net/http"
  5. _ "github.com/rakyll/statik/example/statik"
  6. "github.com/rakyll/statik/fs"
  7. )
  8. // Before buildling, run `statik -src=./public`
  9. // to generate the statik package.
  10. // Then, run the main program and visit http://localhost:8080/public/hello.txt
  11. func main() {
  12. statikFS, err := fs.New()
  13. if err != nil {
  14. log.Fatalf(err.Error())
  15. }
  16. http.Handle("/public/", http.StripPrefix("/public/", http.FileServer(statikFS)))
  17. http.ListenAndServe(":8080", nil)
  18. }