Last active
December 9, 2021 11:43
-
-
Save deepgully/8597490 to your computer and use it in GitHub Desktop.
golang in koding.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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