diff --git a/.gitignore b/.gitignore index f3b636df..618f197d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ vendor/* -!vendor/vendor.json +# vendor backups by dep +_vendor-* coverage.out count.out diff --git a/Gopkg.lock b/Gopkg.lock new file mode 100644 index 00000000..e29799d7 --- /dev/null +++ b/Gopkg.lock @@ -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 diff --git a/Gopkg.toml b/Gopkg.toml new file mode 100644 index 00000000..c729af02 --- /dev/null +++ b/Gopkg.toml @@ -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" diff --git a/Makefile b/Makefile index 9ba475a4..d35cdc06 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*") all: build install: deps - govendor sync + dep ensure .PHONY: test test: @@ -29,8 +29,9 @@ vet: go vet $(PACKAGES) deps: - @hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ - go get -u github.com/kardianos/govendor; \ + @hash dep > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + 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 @hash embedmd > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ go get -u github.com/campoy/embedmd; \ diff --git a/README.md b/README.md index b7181036..e501c7d4 100644 --- a/README.md +++ b/README.md @@ -107,12 +107,12 @@ import "github.com/gin-gonic/gin" 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 -$ go get github.com/kardianos/govendor +$ go get -u github.com/golang/dep/cmd/dep ``` 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 "$_" ``` -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 +3. Copy a starting template inside your project ```sh $ 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 ```sh @@ -272,7 +280,7 @@ id: 1234; page: 1; name: manu; message: this_is_great #### 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 func main() { @@ -303,7 +311,7 @@ curl -X POST http://localhost:8080/upload \ #### Multiple files -See the detail [example code](examples/upload-file/multiple). +See the detail [example code](_examples/upload-file/multiple). ```go func main() { @@ -527,9 +535,9 @@ $ curl -v -X POST \ ### 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 package main @@ -925,7 +933,7 @@ You may use custom delims #### Custom Template Funcs -See the detail [example code](examples/template). +See the detail [example code](_examples/template). main.go @@ -1133,7 +1141,7 @@ func main() { example for 1-line LetsEncrypt HTTPS servers. -[embedmd]:# (examples/auto-tls/example1.go go) +[embedmd]:# (_examples/auto-tls/example1.go go) ```go package main @@ -1158,7 +1166,7 @@ func main() { example for custom autocert manager. -[embedmd]:# (examples/auto-tls/example2.go go) +[embedmd]:# (_examples/auto-tls/example2.go go) ```go package main @@ -1192,7 +1200,7 @@ func main() { 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 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. * [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 // +build go1.8 diff --git a/examples/app-engine/README.md b/_examples/app-engine/README.md similarity index 87% rename from examples/app-engine/README.md rename to _examples/app-engine/README.md index 48505de8..d55cb924 100644 --- a/examples/app-engine/README.md +++ b/_examples/app-engine/README.md @@ -3,5 +3,5 @@ 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` 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/` -5. Run it: `$ goapp serve app-engine/` \ No newline at end of file +4. Navigate to examples folder: `$ cd $GOPATH/src/github.com/gin-gonic/gin/_examples/` +5. Run it: `$ goapp serve app-engine/` diff --git a/examples/app-engine/app.yaml b/_examples/app-engine/app.yaml similarity index 100% rename from examples/app-engine/app.yaml rename to _examples/app-engine/app.yaml diff --git a/examples/app-engine/hello.go b/_examples/app-engine/hello.go similarity index 100% rename from examples/app-engine/hello.go rename to _examples/app-engine/hello.go diff --git a/examples/auto-tls/example1.go b/_examples/auto-tls/example1.go similarity index 100% rename from examples/auto-tls/example1.go rename to _examples/auto-tls/example1.go diff --git a/examples/auto-tls/example2.go b/_examples/auto-tls/example2.go similarity index 100% rename from examples/auto-tls/example2.go rename to _examples/auto-tls/example2.go diff --git a/examples/basic/main.go b/_examples/basic/main.go similarity index 100% rename from examples/basic/main.go rename to _examples/basic/main.go diff --git a/examples/custom-validation/server.go b/_examples/custom-validation/server.go similarity index 100% rename from examples/custom-validation/server.go rename to _examples/custom-validation/server.go diff --git a/examples/favicon/favicon.ico b/_examples/favicon/favicon.ico similarity index 100% rename from examples/favicon/favicon.ico rename to _examples/favicon/favicon.ico diff --git a/examples/favicon/main.go b/_examples/favicon/main.go similarity index 100% rename from examples/favicon/main.go rename to _examples/favicon/main.go diff --git a/examples/graceful-shutdown/close/server.go b/_examples/graceful-shutdown/close/server.go similarity index 100% rename from examples/graceful-shutdown/close/server.go rename to _examples/graceful-shutdown/close/server.go diff --git a/examples/graceful-shutdown/graceful-shutdown/server.go b/_examples/graceful-shutdown/graceful-shutdown/server.go similarity index 100% rename from examples/graceful-shutdown/graceful-shutdown/server.go rename to _examples/graceful-shutdown/graceful-shutdown/server.go diff --git a/examples/http2/README.md b/_examples/http2/README.md similarity index 100% rename from examples/http2/README.md rename to _examples/http2/README.md diff --git a/examples/http2/main.go b/_examples/http2/main.go similarity index 100% rename from examples/http2/main.go rename to _examples/http2/main.go diff --git a/examples/http2/testdata/ca.pem b/_examples/http2/testdata/ca.pem similarity index 100% rename from examples/http2/testdata/ca.pem rename to _examples/http2/testdata/ca.pem diff --git a/examples/http2/testdata/server.key b/_examples/http2/testdata/server.key similarity index 100% rename from examples/http2/testdata/server.key rename to _examples/http2/testdata/server.key diff --git a/examples/http2/testdata/server.pem b/_examples/http2/testdata/server.pem similarity index 100% rename from examples/http2/testdata/server.pem rename to _examples/http2/testdata/server.pem diff --git a/examples/multiple-service/main.go b/_examples/multiple-service/main.go similarity index 100% rename from examples/multiple-service/main.go rename to _examples/multiple-service/main.go diff --git a/examples/realtime-advanced/Makefile b/_examples/realtime-advanced/Makefile similarity index 100% rename from examples/realtime-advanced/Makefile rename to _examples/realtime-advanced/Makefile diff --git a/examples/realtime-advanced/main.go b/_examples/realtime-advanced/main.go similarity index 100% rename from examples/realtime-advanced/main.go rename to _examples/realtime-advanced/main.go diff --git a/examples/realtime-advanced/resources/room_login.templ.html b/_examples/realtime-advanced/resources/room_login.templ.html similarity index 96% rename from examples/realtime-advanced/resources/room_login.templ.html rename to _examples/realtime-advanced/resources/room_login.templ.html index 27dac387..52dd3056 100644 --- a/examples/realtime-advanced/resources/room_login.templ.html +++ b/_examples/realtime-advanced/resources/room_login.templ.html @@ -7,7 +7,7 @@
Server-sent events (SSE) is a technology where a browser receives automatic updates from a server via HTTP connection. It is not websockets. Learn more.
-The chat and the charts data is provided in realtime using the SSE implemention of Gin Framework.
+The chat and the charts data is provided in realtime using the SSE implemention of Gin Framework.