< Server-Side Scripting < Introduction 
 
      server.go
// Displays "Hello world!"
//
// References:
//  https://repl.it/@mauriycf/A-simple-web-server-in-go#main.go
//  https://gowebexamples.com/hello-world/
package main
import (
    "net/http"
    "io"
)
func handler(response http.ResponseWriter, request *http.Request) {
    io.WriteString(response, "Hello world!")
}
func main() {
    http.HandleFunc("/", handler)
    http.ListenAndServe(":8000", nil)
}
Try It
Copy and paste the code above into the following free online development environment or use your own Go compiler / interpreter / IDE.
    This article is issued from Wikiversity. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.