Simple Go Web Server

I created a simple Go web server based on the server I’ve written for

Build and run instructions from the

./; # Builds bin/webserver

./bin/; # kills existing server then runs webserver


Simple Go Web Page (GET Method)

I wanted to give the Go language a try today for a simple web page that I needed. Unfortunately, I got tripped up when I placed an extra / at the end of my handler. Thought I would post the first working copy here before I go off and finish the page. Hopefully, no one else gets burned by that little mistake.

package main

import (

func summaryHandler(w http.ResponseWriter, r *http.Request) {

   var header = `
    <meta http-equiv="Content-Type" content=\"text/html; charset=utf-8">
    <script src=""
    <script src="/js/myjs.js"></script>

    <link rel="stylesheet" href="/css/dictionary.css">
    fmt.Fprint(w, header)
    fmt.Fprint(w, "<h1>Hello World: Simple Go Web Page</h1>")
    params := r.URL.Query()
    fmt.Fprint(w, r.URL)
    fmt.Fprint(w, params)
    param1 := params["param1"]
    param2 := params["param2"]

    fmt.Fprint(w, "<p>Param1=", param1, "</p>")
    fmt.Fprint(w, "<p>Param2=", param2, "</p>")

func setupWeb() {
    // Put static assets in the resources dir
    http.Handle("/", http.FileServer(http.Dir("resources")))
    // WARNING: "/summary/" will cause pain with the GET
    http.HandleFunc("/summary", summaryHandler)

    err := http.ListenAndServe("localhost:3000", nil)
    if err != nil {

func main() {