Essential Go HTTP Server  Edit on GitHub      File Issue

HTTP Hello World with custom server and mux

package main

import (

func main() {

    // Create a mux for routing incoming requests
    m := http.NewServeMux()

    // All URLs will be handled by this function
    m.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("Hello, world!"))

    // Create a server listening on port 8000
    s := &http.Server{
        Addr:    ":8000",
        Handler: m,

    // Continue to process new requests until an error occurs

Press Ctrl+C to stop the process.

  ↑ ↓ to navigate     ↵ to select     Esc to close