Skip to content

Instantly share code, notes, and snippets.

@nbbrdn
Created November 2, 2023 07:13
Show Gist options
  • Save nbbrdn/277b54f35e48320093576443e2b5111b to your computer and use it in GitHub Desktop.
Save nbbrdn/277b54f35e48320093576443e2b5111b to your computer and use it in GitHub Desktop.
Minimal Go Web Server
package main
import (
"fmt"
"net/http"
)
func main() {
server := &http.Server{
Addr: ":3000",
Handler: http.HandlerFunc(basicHandler),
}
err := server.ListenAndServe()
if err != nil {
fmt.Println("failed to listen to server", err)
}
}
func basicHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello, world!"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment