Guides

Quickstart

This page will help you get started with Golf. You'll be up and running in a jiffy!

Before using Golf, please make sure that you have Go installed and setup on your local environment.

You can find instructions on how to install Go at https://golang.org/doc/install.

After you have Go setup on your local environment, you can install Golf by the following command:

$ go get github.com/dinever/golf

You are ready to go after Golf is successfully installed. Simply create the following minimal example of a Golf website:

package main

import "github.com/dinever/golf"

func mainHandler(ctx *golf.Context) {
  ctx.Send("Hello World!")
}

func main() {
  app := golf.New()
  app.Get("/", mainHandler)
  app.Run(":9000")
}

Simply run this application by go run subcommand:

$ go run app.go

Or build this application and run the executable:

$ go build app.go
$ ./app

The website will be available at http://localhost:9000.