Go Hello World Server
This commit is contained in:
parent
b3e5840f60
commit
bdd5e65ebf
1 changed files with 16 additions and 0 deletions
16
go/hello-world-server.go
Normal file
16
go/hello-world-server.go
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
http.HandleFunc("/", homepage)
|
||||||
|
fmt.Println("Server is running on http://localhost:8081")
|
||||||
|
http.ListenAndServe(":8081", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func homepage(w http.ResponseWriter, r *http.Request) {
|
||||||
|
fmt.Fprintf(w, "<h1>Hello World</h1>")
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue