Skip to content

Instantly share code, notes, and snippets.

@ncweinhold
Created June 10, 2012 19:48
Show Gist options
  • Save ncweinhold/2907108 to your computer and use it in GitHub Desktop.
Save ncweinhold/2907108 to your computer and use it in GitHub Desktop.
Dabbling with Go
package main
import (
"net/http"
"fmt"
)
func main() {
http.HandleFunc("/", indexHandler)
http.HandleFunc("/about", aboutHandler)
http.ListenAndServe(":8080", nil)
}
func indexHandler(w http.ResponseWriter, req *http.Request) {
fmt.Fprint(w, indexPage)
}
func aboutHandler(w http.ResponseWriter, req *http.Request) {
fmt.Fprint(w, aboutPage)
}
const indexPage = `
<html>
<head>
<title>Simple Web App With Go</title>
</head>
<body>
<h1>Simple Web App</h1>
<p>This is a simple web application built using Go.</p>
</body>
</html>
`
const aboutPage = `
<html>
<head>
<title>About</title>
</head>
<body>
<h1>About</h1>
<p>This is a simple web application created using Go.</p>
</body>
</html>
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment