forked from golang/go
-
Notifications
You must be signed in to change notification settings - Fork 0
HttpStaticFiles
Dave Day edited this page Dec 10, 2014
·
5 revisions
#summary Serving static files with HTTP. #labels http
The HTTP package provides good support for efficiently serving static files.
This is a complete Go webserver serving static files:
package main
import "net/http"
func main() {
panic(http.ListenAndServe(":8080", http.FileServer(http.Dir("/usr/share/doc"))))
}
That example is intentionally short to make a point. Using panic() to deal with an error is probably too aggressive & would produce too much output. More typical style would be:
See the net/http documentation and in particular the FileServer example for more details.
- Home
- Getting started with Go
- Working with Go
- Learning more about Go
- The Go Community
- Using the Go toolchain
- Additional Go Programming Wikis
- Online Services that work with Go
- Troubleshooting Go Programs in Production
- Contributing to the Go Project
- Platform Specific Information
- Release Specific Information