Skip to content

Instantly share code, notes, and snippets.

@deepgully
Last active December 9, 2021 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepgully/8597490 to your computer and use it in GitHub Desktop.
Save deepgully/8597490 to your computer and use it in GitHub Desktop.
golang in koding.com
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)
}
}
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment