https://github.com/dinever/golf
:golf: The Golf web framework
https://github.com/dinever/golf
framework go golf middleware router server web webframework
Last synced: 10 months ago
JSON representation
:golf: The Golf web framework
- Host: GitHub
- URL: https://github.com/dinever/golf
- Owner: dinever
- License: mit
- Created: 2015-11-18T15:10:14.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2021-08-27T22:20:34.000Z (over 4 years ago)
- Last Synced: 2025-03-31T11:08:19.225Z (10 months ago)
- Topics: framework, go, golf, middleware, router, server, web, webframework
- Language: Go
- Homepage: https://golf.readme.io/
- Size: 191 KB
- Stars: 269
- Watchers: 17
- Forks: 29
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- go-awesome-with-star-updatetime - Golf - Golf is a fast, simple and lightweight micro-web framework for Go. It comes with powerful features and has no dependencies other than the Go Standard Library. (Web Frameworks / HTTP Clients)
- awesome-go-cn - Golf
- awesome-go-extra - golf - 11-18T15:10:14Z|2021-08-27T22:20:34Z| (Web Frameworks / Fail injection)
- awesome-go - Golf - Golf is a fast, simple and lightweight micro-web framework for Go. It comes with powerful features and has no dependencies other than the Go Standard Library. (Web Frameworks / <span id="高级控制台用户界面-advanced-console-uis">高级控制台用户界面 Advanced Console UIs</span>)
- awesome-go - Golf - Golf is a fast, simple and lightweight micro-web framework for Go. It comes with powerful features and has no dependencies other than the Go Standard Library. (Web Frameworks / Utility/Miscellaneous)
- awesome-go - Golf - Golf is a fast, simple and lightweight micro-web framework for Go. It comes with powerful features and has no dependencies other than the Go Standard Library. (Web Frameworks / Advanced Console UIs)
- awesome-go - golf - The Golf web framework - ★ 229 (Web Frameworks)
- awesome-go - Golf - Golf is a fast, simple and lightweight micro-web framework for Go. It comes with powerful features and has no dependencies other than the Go Standard Library. (Web Frameworks / Utility/Miscellaneous)
- fucking-awesome-go - :octocat: Golf - Golf is a fast, simple and lightweight micro-web framework for Go. It comes with powerful features and has no dependencies other than the Go Standard Library. :star: 170 :fork_and_knife: 10 (Web Frameworks / Advanced Console UIs)
- awesome-go-cn - Golf - web framework for Go. It comes with powerful features and has no dependencies other than the Go Standard Library.) (Web框架 / Advanced Console UIs)
- awesome-go - Golf - Golf is a fast, simple and lightweight micro-web framework for Go. It comes with powerful features and has no dependencies other than the Go Standard Library. (Web Frameworks / HTTP Clients)
- awesome-go-zh - Golf
- awesome-go - Golf - Golf is a fast, simple and lightweight micro-web framework for Go. It comes with powerful features and has no dependencies other than the Go Standard Library. (Web Frameworks / Utility/Miscellaneous)
- awesome-Char - Golf - Golf is a fast, simple and lightweight micro-web framework for Go. It comes with powerful features and has no dependencies other than the Go Standard Library. (Web Frameworks / HTTP Clients)
- awesome-go - Golf - web framework for Go. It comes with powerful features and has no dependencies other than the Go Standard Library. | 233 | 22 | 5 | (Web Frameworks / HTTP Clients)
- awesome-go - Golf - Golf is a fast, simple and lightweight micro-web framework for Go. It comes with powerful features and has no dependencies other than the Go Standard Library. (Web Frameworks / Utility/Miscellaneous)
- awesome-go-cn - Golf
- awesome-go - Golf - Golf is a fast, simple and lightweight micro-web framework for Go. It comes with powerful features and has no dependencies other than the Go Standard Library. - :arrow_down:40 - :star:179 (Web Frameworks / HTTP Clients)
README
[](http://golf.readme.io/docs)
[](https://raw.githubusercontent.com/dinever/golf/master/LICENSE)
[](https://travis-ci.org/dinever/golf)
[](https://travis-ci.org/dinever/golf)
[](https://coveralls.io/r/dinever/golf?branch=master)
A fast, simple and lightweight micro-web framework for Go, comes with powerful features and has no dependencies other than the Go Standard Library.
Homepage: [golf.readme.io](https://golf.readme.io/)
## Installation
go get github.com/dinever/golf
## Features
1. No allocation during routing and parameter retrieve.
1. Dead simple template inheritance with `extends` and `include` helper comes out of box.
**layout.html**
```html
Hello World
{{ template "body" }}
{{ include "sidebar.html" }}
```
**index.html**
```jinja2
{{ extends "layout.html" }}
{{ define "body"}}
Main content
{{ end }}
```
**sidebar.html**
```jinja2
Sidebar content
```
1. Built-in XSRF and Session support.
1. Powerful middleware chain.
1. Configuration from JSON file.
## Hello World
```go
package main
import "github.com/dinever/golf"
func mainHandler(ctx *golf.Context) {
ctx.Send("Hello World!")
}
func pageHandler(ctx *golf.Context) {
ctx.Send("Page: " + ctx.Param("page"))
}
func main() {
app := golf.New()
app.Get("/", mainHandler)
app.Get("/p/:page/", pageHandler)
app.Run(":9000")
}
```
The website will be available at http://localhost:9000.
## Benchmark
The following chart shows the benchmark performance of Golf compared with others.

For more information, please see [BENCHMARKING.md](BENCHMARKING.md)
## Docs
[golf.readme.io/docs](https://golf.readme.io/docs)
## License
[MIT License](/LICENSE)
