Skip to content

Instantly share code, notes, and snippets.

@narqo
Created February 14, 2019 12:17
Show Gist options
  • Save narqo/c87164fc29902378b3a0ae6d7b0731c5 to your computer and use it in GitHub Desktop.
Save narqo/c87164fc29902378b3a0ae6d7b0731c5 to your computer and use it in GitHub Desktop.
package main
import (
"net"
"net/http"
)
const addr = ":8080"
func main() {
srv := &http.Server{/* ··· */}
ln, _ := net.Listen("tcp", addr)
log.Print("server is running on %s", addr)
// Note, net/http.ListenAndServe uses tcpKeepAliveListener
// see https://codereview.appspot.com/48300043/ for the backstory
srv.Serve(ln)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment