From 8373cac8f86c66903239621659ee657f6593040e Mon Sep 17 00:00:00 2001 From: thinkerou Date: Thu, 14 Jun 2018 16:18:48 +0800 Subject: [PATCH 1/4] add go version prerequisite and debug warning --- README.md | 14 ++++++++++++++ debug.go | 3 +++ debug_test.go | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0bac65b2..c0447814 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Gin is a web framework written in Go (Golang). It features a martini-like API wi ## Contents +- [Installation](#installation) +- [Prerequisite](#prerequisite) - [Quick start](#quick-start) - [Benchmarks](#benchmarks) - [Gin v1.stable](#gin-v1-stable) @@ -57,6 +59,18 @@ Gin is a web framework written in Go (Golang). It features a martini-like API wi - [Testing](#testing) - [Users](#users--) +## Installation + +To install Gin package, you need to install Go and set your Go workspace. The simplest way to install the library is to run: + +```sh +$ go get -u github.com/gin-gonic/gin +``` + +## Prerequisite + +Now Gin requires Go 1.6 or later and Go 1.7 will be required soon. + ## Quick start ```sh diff --git a/debug.go b/debug.go index 897c4943..f11156b3 100644 --- a/debug.go +++ b/debug.go @@ -47,6 +47,9 @@ func debugPrint(format string, values ...interface{}) { } func debugPrintWARNINGDefault() { + debugPrint(`[WARNING] Now Gin requires Go 1.6 or later and Go 1.7 will be required soon. + +`) debugPrint(`[WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached. `) diff --git a/debug_test.go b/debug_test.go index dfd54c82..440173b7 100644 --- a/debug_test.go +++ b/debug_test.go @@ -92,7 +92,7 @@ func TestDebugPrintWARNINGDefault(t *testing.T) { defer teardown() debugPrintWARNINGDefault() - assert.Equal(t, "[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.\n\n", w.String()) + assert.Equal(t, "[GIN-debug] [WARNING] Now Gin requires Go 1.6 or later and Go 1.7 will be required soon.\n\n[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.\n\n", w.String()) } func TestDebugPrintWARNINGNew(t *testing.T) { From 794bf11db52a0f94000ba00ceedbfd216809765b Mon Sep 17 00:00:00 2001 From: thinkerou Date: Thu, 14 Jun 2018 16:42:40 +0800 Subject: [PATCH 2/4] merge duplicate content --- README.md | 105 ++++++++++++++++++++++++++---------------------------- 1 file changed, 51 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index c0447814..a72c795e 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ Gin is a web framework written in Go (Golang). It features a martini-like API wi - [Quick start](#quick-start) - [Benchmarks](#benchmarks) - [Gin v1.stable](#gin-v1-stable) -- [Start using it](#start-using-it) - [Build with jsoniter](#build-with-jsoniter) - [API Examples](#api-examples) - [Using GET,POST,PUT,PATCH,DELETE and OPTIONS](#using-get-post-put-patch-delete-and-options) @@ -61,12 +60,62 @@ Gin is a web framework written in Go (Golang). It features a martini-like API wi ## Installation -To install Gin package, you need to install Go and set your Go workspace. The simplest way to install the library is to run: +To install Gin package, you need to install Go and set your Go workspace first. + +1. Download and install it: ```sh $ go get -u github.com/gin-gonic/gin ``` +2. Import it in your code: + +```go +import "github.com/gin-gonic/gin" +``` + +3. (Optional) Import `net/http`. This is required for example if using constants such as `http.StatusOK`. + +```go +import "net/http" +``` + +```sh +$ go get -u github.com/gin-gonic/gin +``` + +### Use a vendor tool like [Govendor](https://github.com/kardianos/govendor) + +1. `go get` govendor + +```sh +$ go get github.com/kardianos/govendor +``` +2. Create your project folder and `cd` inside + +```sh +$ mkdir -p $GOPATH/src/github.com/myusername/project && cd "$_" +``` + +3. Vendor init your project and add gin + +```sh +$ govendor init +$ govendor fetch github.com/gin-gonic/gin@v1.2 +``` + +4. Copy a starting template inside your project + +```sh +$ curl https://raw.githubusercontent.com/gin-gonic/gin/master/examples/basic/main.go > main.go +``` + +5. Run your project + +```sh +$ go run main.go +``` + ## Prerequisite Now Gin requires Go 1.6 or later and Go 1.7 will be required soon. @@ -148,58 +197,6 @@ BenchmarkVulcan_GithubAll | 5000 | 394253 | 19894 - [x] Battle tested - [x] API frozen, new releases will not break your code. -## Start using it - -1. Download and install it: - -```sh -$ go get github.com/gin-gonic/gin -``` - -2. Import it in your code: - -```go -import "github.com/gin-gonic/gin" -``` - -3. (Optional) Import `net/http`. This is required for example if using constants such as `http.StatusOK`. - -```go -import "net/http" -``` - -### Use a vendor tool like [Govendor](https://github.com/kardianos/govendor) - -1. `go get` govendor - -```sh -$ go get github.com/kardianos/govendor -``` -2. Create your project folder and `cd` inside - -```sh -$ mkdir -p $GOPATH/src/github.com/myusername/project && cd "$_" -``` - -3. Vendor init your project and add gin - -```sh -$ govendor init -$ govendor fetch github.com/gin-gonic/gin@v1.2 -``` - -4. Copy a starting template inside your project - -```sh -$ curl https://raw.githubusercontent.com/gin-gonic/gin/master/examples/basic/main.go > main.go -``` - -5. Run your project - -```sh -$ go run main.go -``` - ## Build with [jsoniter](https://github.com/json-iterator/go) Gin use `encoding/json` as default json package but you can change to [jsoniter](https://github.com/json-iterator/go) by build from other tags. From 3cd3ed67a474ce4672c4f0cd1739a3f8335a8f13 Mon Sep 17 00:00:00 2001 From: thinkerou Date: Thu, 14 Jun 2018 21:29:42 +0800 Subject: [PATCH 3/4] remove duplicate content --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index a72c795e..24386dcd 100644 --- a/README.md +++ b/README.md @@ -80,10 +80,6 @@ import "github.com/gin-gonic/gin" import "net/http" ``` -```sh -$ go get -u github.com/gin-gonic/gin -``` - ### Use a vendor tool like [Govendor](https://github.com/kardianos/govendor) 1. `go get` govendor From ccde21e253a293d35697a17ef54fb2ffe3fe14f1 Mon Sep 17 00:00:00 2001 From: thinkerou Date: Fri, 22 Jun 2018 12:24:00 +0800 Subject: [PATCH 4/4] fix typo to bug --- examples/grpc/gin/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/grpc/gin/main.go b/examples/grpc/gin/main.go index c21692ae..edc1ca9b 100644 --- a/examples/grpc/gin/main.go +++ b/examples/grpc/gin/main.go @@ -26,7 +26,7 @@ func main() { // Contact the server and print out its response. req := &pb.HelloRequest{Name: name} - res, err := client.SayHello(g, req) + res, err := client.SayHello(c, req) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{ "error": err.Error(),