sobota, 18 czerwca 2016

Very nice simple go lang http server

package main

import "fmt"
import "net/http"

func handler(w http.ResponseWriter, r *http.Request){
  fmt.Println("Inside handler")
  fmt.Fprintf(w, "Hello world from my go program\n")
}

func main(){
  http.HandleFunc("/",handler) //redirect all urls to handler function
  http.ListenAndServe("localhost:9999",nil)
}

Brak komentarzy:

Prześlij komentarz