Wednesday, July 02, 2014

Go Lang: Web Server

Writing Web Applications - The Go Programming Language
Here's a full working example of a simple web server:
package main

import (
    "fmt"
    "net/http"
)

func handler(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
}

func main() {
    http.HandleFunc("/", handler)
    http.ListenAndServe(":8080", nil)
}



No comments: