webwesen
3/1/2015 - 4:08 AM

hello.go

#!/bin/bash

echo Stop Apache2

sudo service apache2 stop

echo Format Source Code...
go fmt hello.go
echo Build go package
go build hello.go
echo run go server
sudo ./hello
package main

import (
	"fmt"
	"log"
	"net/http"
)

func helloworld(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintf(w, "Hello Go World!")
}

func main() {
    port := 80
	fmt.Println("Start Listen port ", port)
	http.HandleFunc("/", helloworld)
	err := http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
	if err != nil {
		log.Fatal("Error in ListenAndServe: ", err)
	}
}