Merge ae14efe733c10237189558b3ce77cfd068d93020 into 76ad15ab32d000115cb7622a8317d7425dfc039c

This commit is contained in:
Suhas Karanth 2017-11-02 16:53:58 +00:00 committed by GitHub
commit 7a44cc12f2
45 changed files with 181 additions and 147 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
vendor/* vendor/*
!vendor/vendor.json # vendor backups by dep
_vendor-*
coverage.out coverage.out
count.out count.out

81
Gopkg.lock generated Normal file
View File

@ -0,0 +1,81 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
name = "github.com/davecgh/go-spew"
packages = ["spew"]
revision = "346938d642f2ec3594ed81d874461961cd0faa76"
version = "v1.1.0"
[[projects]]
branch = "master"
name = "github.com/gin-contrib/sse"
packages = ["."]
revision = "22d885f9ecc78bf4ee5d72b937e4bbcdc58e8cae"
[[projects]]
branch = "master"
name = "github.com/golang/protobuf"
packages = ["proto"]
revision = "130e6b02ab059e7b717a096f397c5b60111cae74"
[[projects]]
name = "github.com/json-iterator/go"
packages = ["."]
revision = "6240e1e7983a85228f7fd9c3e1b6932d46ec58e2"
version = "1.0.3"
[[projects]]
name = "github.com/mattn/go-isatty"
packages = ["."]
revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
version = "v0.0.3"
[[projects]]
name = "github.com/pmezard/go-difflib"
packages = ["difflib"]
revision = "792786c7400a136282c1664665ae0a8db921c6c2"
version = "v1.0.0"
[[projects]]
name = "github.com/stretchr/testify"
packages = ["assert"]
revision = "69483b4bd14f5845b5a1e55bca19e954e827f1d0"
version = "v1.1.4"
[[projects]]
branch = "master"
name = "github.com/ugorji/go"
packages = ["codec"]
revision = "f76f59a92f8224c695c0e2c401b9ad17e820a8f5"
[[projects]]
branch = "master"
name = "golang.org/x/net"
packages = ["context"]
revision = "a04bdaca5b32abe1c069418fb7088ae607de5bd0"
[[projects]]
branch = "master"
name = "golang.org/x/sys"
packages = ["unix"]
revision = "43eea11bc92608addb41b8a406b0407495c106f6"
[[projects]]
name = "gopkg.in/go-playground/validator.v8"
packages = ["."]
revision = "5f1438d3fca68893a817e4a66806cea46a9e4ebf"
version = "v8.18.2"
[[projects]]
branch = "v2"
name = "gopkg.in/yaml.v2"
packages = ["."]
revision = "eb3733d160e74a9c7e442f435eb3bea458e1d19f"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "4194bcea657c57404cc411768579588cd0ab1e71f05c0f9b3bb6a843a41f5531"
solver-name = "gps-cdcl"
solver-version = 1

58
Gopkg.toml Normal file
View File

@ -0,0 +1,58 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
[[constraint]]
branch = "master"
name = "github.com/gin-contrib/sse"
[[constraint]]
branch = "master"
name = "github.com/golang/protobuf"
[[constraint]]
name = "github.com/json-iterator/go"
version = "1.0.3"
[[constraint]]
name = "github.com/mattn/go-isatty"
version = "0.0.3"
[[constraint]]
name = "github.com/stretchr/testify"
version = "1.1.4"
[[constraint]]
branch = "master"
name = "github.com/ugorji/go"
[[constraint]]
branch = "master"
name = "golang.org/x/net"
[[constraint]]
name = "gopkg.in/go-playground/validator.v8"
version = "8.18.2"
[[constraint]]
branch = "v2"
name = "gopkg.in/yaml.v2"

View File

@ -5,7 +5,7 @@ GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")
all: build all: build
install: deps install: deps
govendor sync dep ensure
.PHONY: test .PHONY: test
test: test:
@ -29,8 +29,9 @@ vet:
go vet $(PACKAGES) go vet $(PACKAGES)
deps: deps:
@hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ @hash dep > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go get -u github.com/kardianos/govendor; \ curl -L -s https://github.com/golang/dep/releases/download/v0.3.2/dep-linux-amd64 -o $(GOPATH)/bin/dep; \
chmod +x $(GOPATH)/bin/dep; \
fi fi
@hash embedmd > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ @hash embedmd > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go get -u github.com/campoy/embedmd; \ go get -u github.com/campoy/embedmd; \

View File

@ -107,12 +107,12 @@ import "github.com/gin-gonic/gin"
import "net/http" import "net/http"
``` ```
### Use a vendor tool like [Govendor](https://github.com/kardianos/govendor) ### Use a vendor tool like [`dep`](https://github.com/golang/dep)
1. `go get` govendor 1. `go get` dep
```sh ```sh
$ go get github.com/kardianos/govendor $ go get -u github.com/golang/dep/cmd/dep
``` ```
2. Create your project folder and `cd` inside 2. Create your project folder and `cd` inside
@ -120,19 +120,27 @@ $ go get github.com/kardianos/govendor
$ mkdir -p ~/go/src/github.com/myusername/project && cd "$_" $ mkdir -p ~/go/src/github.com/myusername/project && cd "$_"
``` ```
3. Vendor init your project and add gin 3. Copy a starting template inside your project
```sh
$ govendor init
$ govendor fetch github.com/gin-gonic/gin@v1.2
```
4. Copy a starting template inside your project
```sh ```sh
$ curl https://raw.githubusercontent.com/gin-gonic/gin/master/examples/basic/main.go > main.go $ curl https://raw.githubusercontent.com/gin-gonic/gin/master/examples/basic/main.go > main.go
``` ```
4. Vendor init your project and pull in the required dependencies into `vendor`
```sh
$ dep init
Locking in v8.18.2 (5f1438d) for transitive dep gopkg.in/go-playground/validator.v8
Locking in v0.0.3 (0360b2a) for transitive dep github.com/mattn/go-isatty
Locking in master (8dbc5d0) for transitive dep golang.org/x/sys
Locking in v2 (eb3733d) for transitive dep gopkg.in/yaml.v2
Using ^1.2.0 as constraint for direct dep github.com/gin-gonic/gin
Locking in v1.2 (d459835) for direct dep github.com/gin-gonic/gin
Locking in master (22d885f) for transitive dep github.com/gin-contrib/sse
Locking in master (1643683) for transitive dep github.com/golang/protobuf
Locking in master (bdcc60b) for transitive dep github.com/ugorji/go
```
5. Run your project 5. Run your project
```sh ```sh
@ -272,7 +280,7 @@ id: 1234; page: 1; name: manu; message: this_is_great
#### Single file #### Single file
References issue [#774](https://github.com/gin-gonic/gin/issues/774) and detail [example code](examples/upload-file/single). References issue [#774](https://github.com/gin-gonic/gin/issues/774) and detail [example code](_examples/upload-file/single).
```go ```go
func main() { func main() {
@ -303,7 +311,7 @@ curl -X POST http://localhost:8080/upload \
#### Multiple files #### Multiple files
See the detail [example code](examples/upload-file/multiple). See the detail [example code](_examples/upload-file/multiple).
```go ```go
func main() { func main() {
@ -527,9 +535,9 @@ $ curl -v -X POST \
### Custom Validators ### Custom Validators
It is also possible to register custom validators. See the [example code](examples/custom-validation/server.go). It is also possible to register custom validators. See the [example code](_examples/custom-validation/server.go).
[embedmd]:# (examples/custom-validation/server.go go) [embedmd]:# (_examples/custom-validation/server.go go)
```go ```go
package main package main
@ -925,7 +933,7 @@ You may use custom delims
#### Custom Template Funcs #### Custom Template Funcs
See the detail [example code](examples/template). See the detail [example code](_examples/template).
main.go main.go
@ -1133,7 +1141,7 @@ func main() {
example for 1-line LetsEncrypt HTTPS servers. example for 1-line LetsEncrypt HTTPS servers.
[embedmd]:# (examples/auto-tls/example1.go go) [embedmd]:# (_examples/auto-tls/example1.go go)
```go ```go
package main package main
@ -1158,7 +1166,7 @@ func main() {
example for custom autocert manager. example for custom autocert manager.
[embedmd]:# (examples/auto-tls/example2.go go) [embedmd]:# (_examples/auto-tls/example2.go go)
```go ```go
package main package main
@ -1192,7 +1200,7 @@ func main() {
See the [question](https://github.com/gin-gonic/gin/issues/346) and try the folling example: See the [question](https://github.com/gin-gonic/gin/issues/346) and try the folling example:
[embedmd]:# (examples/multiple-service/main.go go) [embedmd]:# (_examples/multiple-service/main.go go)
```go ```go
package main package main
@ -1290,9 +1298,9 @@ An alternative to endless:
* [graceful](https://github.com/tylerb/graceful): Graceful is a Go package enabling graceful shutdown of an http.Handler server. * [graceful](https://github.com/tylerb/graceful): Graceful is a Go package enabling graceful shutdown of an http.Handler server.
* [grace](https://github.com/facebookgo/grace): Graceful restart & zero downtime deploy for Go servers. * [grace](https://github.com/facebookgo/grace): Graceful restart & zero downtime deploy for Go servers.
If you are using Go 1.8, you may not need to use this library! Consider using http.Server's built-in [Shutdown()](https://golang.org/pkg/net/http/#Server.Shutdown) method for graceful shutdowns. See the full [graceful-shutdown](./examples/graceful-shutdown) example with gin. If you are using Go 1.8, you may not need to use this library! Consider using http.Server's built-in [Shutdown()](https://golang.org/pkg/net/http/#Server.Shutdown) method for graceful shutdowns. See the full [graceful-shutdown](_examples/graceful-shutdown) example with gin.
[embedmd]:# (examples/graceful-shutdown/graceful-shutdown/server.go go) [embedmd]:# (_examples/graceful-shutdown/graceful-shutdown/server.go go)
```go ```go
// +build go1.8 // +build go1.8

View File

@ -3,5 +3,5 @@
1. Download, install and setup Go in your computer. (That includes setting your `$GOPATH`.) 1. Download, install and setup Go in your computer. (That includes setting your `$GOPATH`.)
2. Download SDK for your platform from here: `https://developers.google.com/appengine/downloads?hl=es#Google_App_Engine_SDK_for_Go` 2. Download SDK for your platform from here: `https://developers.google.com/appengine/downloads?hl=es#Google_App_Engine_SDK_for_Go`
3. Download Gin source code using: `$ go get github.com/gin-gonic/gin` 3. Download Gin source code using: `$ go get github.com/gin-gonic/gin`
4. Navigate to examples folder: `$ cd $GOPATH/src/github.com/gin-gonic/gin/examples/` 4. Navigate to examples folder: `$ cd $GOPATH/src/github.com/gin-gonic/gin/_examples/`
5. Run it: `$ goapp serve app-engine/` 5. Run it: `$ goapp serve app-engine/`

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -49,7 +49,7 @@
<li><a href="http://www.w3.org/TR/2009/WD-eventsource-20091029/">W3 Standard</a></li> <li><a href="http://www.w3.org/TR/2009/WD-eventsource-20091029/">W3 Standard</a></li>
<li><a href="http://caniuse.com/#feat=eventsource">Browser Support</a></li> <li><a href="http://caniuse.com/#feat=eventsource">Browser Support</a></li>
<li><a href="http://gin-gonic.github.io/gin/">Gin Framework</a></li> <li><a href="http://gin-gonic.github.io/gin/">Gin Framework</a></li>
<li><a href="https://github.com/gin-gonic/gin/tree/develop/examples/realtime-advanced">Github</a></li> <li><a href="https://github.com/gin-gonic/gin/tree/develop/_examples/realtime-advanced">Github</a></li>
</ul> </ul>
</div><!-- /.nav-collapse --> </div><!-- /.nav-collapse -->
</div><!-- /.container --> </div><!-- /.container -->
@ -59,7 +59,7 @@
<div class="container"> <div class="container">
<h1>Server-Sent Events in Go</h1> <h1>Server-Sent Events in Go</h1>
<p>Server-sent events (SSE) is a technology where a browser receives automatic updates from a server via HTTP connection. It is not websockets. <a href="http://www.html5rocks.com/en/tutorials/eventsource/basics/">Learn more.</a></p> <p>Server-sent events (SSE) is a technology where a browser receives automatic updates from a server via HTTP connection. It is not websockets. <a href="http://www.html5rocks.com/en/tutorials/eventsource/basics/">Learn more.</a></p>
<p>The chat and the charts data is provided in realtime using the SSE implemention of <a href="https://github.com/gin-gonic/gin/blob/15b0c49da556d58a3d934b86e3aa552ff224026d/examples/realtime-chat/main.go#L23-L32">Gin Framework</a>.</p> <p>The chat and the charts data is provided in realtime using the SSE implemention of <a href="https://github.com/gin-gonic/gin/blob/15b0c49da556d58a3d934b86e3aa552ff224026d/_examples/realtime-chat/main.go#L23-L32">Gin Framework</a>.</p>
<div class="row"> <div class="row">
<div class="col-md-8"> <div class="col-md-8">
<div id="chat-scroll" style="overflow-y:scroll; overflow-x:scroll; height:290px"> <div id="chat-scroll" style="overflow-y:scroll; overflow-x:scroll; height:290px">
@ -134,7 +134,7 @@
<div class="row"> <div class="row">
<h2>MIT Open Sourced</h2> <h2>MIT Open Sourced</h2>
<ul> <ul>
<li><a href="https://github.com/gin-gonic/gin/tree/develop/examples/realtime-advanced">This demo website (JS and Go)</a></li> <li><a href="https://github.com/gin-gonic/gin/tree/develop/_examples/realtime-advanced">This demo website (JS and Go)</a></li>
<li><a href="https://github.com/manucorporat/sse">The SSE implementation in Go</a></li> <li><a href="https://github.com/manucorporat/sse">The SSE implementation in Go</a></li>
<li><a href="https://github.com/gin-gonic/gin">The Web Framework (Gin)</a></li> <li><a href="https://github.com/gin-gonic/gin">The Web Framework (Gin)</a></li>
</ul> </ul>

115
vendor/vendor.json vendored
View File

@ -1,115 +0,0 @@
{
"comment": "v1.2",
"ignore": "test",
"package": [
{
"checksumSHA1": "dvabztWVQX8f6oMLRyv4dLH+TGY=",
"comment": "v1.1.0",
"path": "github.com/davecgh/go-spew/spew",
"revision": "346938d642f2ec3594ed81d874461961cd0faa76",
"revisionTime": "2016-10-29T20:57:26Z"
},
{
"checksumSHA1": "7c3FuEadBInl/4ExSrB7iJMXpe4=",
"path": "github.com/dustin/go-broadcast",
"revision": "3bdf6d4a7164a50bc19d5f230e2981d87d2584f1",
"revisionTime": "2014-06-27T04:00:55Z"
},
{
"checksumSHA1": "QeKwBtN2df+j+4stw3bQJ6yO4EY=",
"path": "github.com/gin-contrib/sse",
"revision": "22d885f9ecc78bf4ee5d72b937e4bbcdc58e8cae",
"revisionTime": "2017-01-09T09:34:21Z"
},
{
"checksumSHA1": "FJKrZuFmeLJp8HDeJc6UkIDBPUw=",
"path": "github.com/gin-gonic/autotls",
"revision": "5b3297bdcee778ff3bbdc99ab7c41e1c2677d22d",
"revisionTime": "2017-04-16T09:39:34Z"
},
{
"checksumSHA1": "qlPUeFabwF4RKAOF1H+yBFU1Veg=",
"path": "github.com/golang/protobuf/proto",
"revision": "5a0f697c9ed9d68fef0116532c6e05cfeae00e55",
"revisionTime": "2017-06-01T23:02:30Z"
},
{
"checksumSHA1": "Ajh8TemnItg4nn+jKmVcsMRALBc=",
"path": "github.com/json-iterator/go",
"revision": "36b14963da70d11297d313183d7e6388c8510e1e",
"revisionTime": "2017-08-29T15:58:51Z"
},
{
"checksumSHA1": "9if9IBLsxkarJ804NPWAzgskIAk=",
"path": "github.com/manucorporat/stats",
"revision": "8f2d6ace262eba462e9beb552382c98be51d807b",
"revisionTime": "2015-05-31T20:46:25Z"
},
{
"checksumSHA1": "U6lX43KDDlNOn+Z0Yyww+ZzHfFo=",
"path": "github.com/mattn/go-isatty",
"revision": "57fdcb988a5c543893cc61bce354a6e24ab70022",
"revisionTime": "2017-03-07T16:30:44Z"
},
{
"checksumSHA1": "LuFv4/jlrmFNnDb/5SCSEPAM9vU=",
"comment": "v1.0.0",
"path": "github.com/pmezard/go-difflib/difflib",
"revision": "792786c7400a136282c1664665ae0a8db921c6c2",
"revisionTime": "2016-01-10T10:55:54Z"
},
{
"checksumSHA1": "Q2V7Zs3diLmLfmfbiuLpSxETSuY=",
"comment": "v1.1.4",
"path": "github.com/stretchr/testify/assert",
"revision": "976c720a22c8eb4eb6a0b4348ad85ad12491a506",
"revisionTime": "2016-09-25T22:06:09Z"
},
{
"checksumSHA1": "CoxdaTYdPZNJXr8mJfLxye428N0=",
"path": "github.com/ugorji/go/codec",
"revision": "c88ee250d0221a57af388746f5cf03768c21d6e2",
"revisionTime": "2017-02-15T20:11:44Z"
},
{
"checksumSHA1": "W0j4I7QpxXlChjyhAojZmFjU6Bg=",
"path": "golang.org/x/crypto/acme",
"revision": "adbae1b6b6fb4b02448a0fc0dbbc9ba2b95b294d",
"revisionTime": "2017-06-19T06:03:41Z"
},
{
"checksumSHA1": "TrKJW+flz7JulXU3sqnBJjGzgQc=",
"path": "golang.org/x/crypto/acme/autocert",
"revision": "adbae1b6b6fb4b02448a0fc0dbbc9ba2b95b294d",
"revisionTime": "2017-06-19T06:03:41Z"
},
{
"checksumSHA1": "9jjO5GjLa0XF/nfWihF02RoH4qc=",
"comment": "release-branch.go1.7",
"path": "golang.org/x/net/context",
"revision": "d4c55e66d8c3a2f3382d264b08e3e3454a66355a",
"revisionTime": "2016-10-18T08:54:36Z"
},
{
"checksumSHA1": "TVEkpH3gq84iQ39I4R+mlDwjuVI=",
"path": "golang.org/x/sys/unix",
"revision": "99f16d856c9836c42d24e7ab64ea72916925fa97",
"revisionTime": "2017-03-08T15:04:45Z"
},
{
"checksumSHA1": "39V1idWER42Lmcmg2Uy40wMzOlo=",
"comment": "v8.18.1",
"path": "gopkg.in/go-playground/validator.v8",
"revision": "5f57d2222ad794d0dffb07e664ea05e2ee07d60c",
"revisionTime": "2016-07-18T13:41:25Z"
},
{
"checksumSHA1": "12GqsW8PiRPnezDDy0v4brZrndM=",
"comment": "v2",
"path": "gopkg.in/yaml.v2",
"revision": "a5b47d31c556af34a302ce5d659e6fea44d90de0",
"revisionTime": "2016-09-28T15:37:09Z"
}
],
"rootPath": "github.com/gin-gonic/gin"
}