Server-Side Scripting/Introduction/Go

From Wikiversity
Jump to navigation Jump to search

server.go[edit | edit source]

// Displays "Hello world!"
// References:

package main

import (

func handler(response http.ResponseWriter, request *http.Request) {
    io.WriteString(response, "Hello world!")

func main() {
    http.HandleFunc("/", handler)
    http.ListenAndServe(":8000", nil)

Try It[edit | edit source]

Copy and paste the code above into the following free online development environment or use your own Go compiler / interpreter / IDE.