├── vendor
├── github.com
│ ├── modern-go
│ │ ├── reflect2
│ │ │ ├── reflect2_amd64.s
│ │ │ ├── relfect2_386.s
│ │ │ ├── relfect2_arm.s
│ │ │ ├── relfect2_arm64.s
│ │ │ ├── relfect2_mipsx.s
│ │ │ ├── relfect2_s390x.s
│ │ │ ├── relfect2_amd64p32.s
│ │ │ ├── relfect2_mips64x.s
│ │ │ ├── relfect2_ppc64x.s
│ │ │ ├── go_below_17.go
│ │ │ ├── go_above_17.go
│ │ │ ├── go_below_19.go
│ │ │ ├── go_above_19.go
│ │ │ ├── test.sh
│ │ │ ├── Gopkg.lock
│ │ │ ├── Gopkg.toml
│ │ │ ├── safe_struct.go
│ │ │ ├── reflect2_kind.go
│ │ │ ├── unsafe_ptr.go
│ │ │ ├── safe_field.go
│ │ │ ├── unsafe_eface.go
│ │ │ ├── unsafe_iface.go
│ │ │ ├── unsafe_struct.go
│ │ │ ├── safe_type.go
│ │ │ ├── unsafe_array.go
│ │ │ ├── unsafe_field.go
│ │ │ ├── unsafe_type.go
│ │ │ ├── README.md
│ │ │ ├── safe_slice.go
│ │ │ ├── unsafe_link.go
│ │ │ └── safe_map.go
│ │ └── concurrent
│ │ │ ├── go_above_19.go
│ │ │ ├── test.sh
│ │ │ ├── log.go
│ │ │ ├── executor.go
│ │ │ ├── go_below_19.go
│ │ │ └── README.md
│ ├── gin-gonic
│ │ ├── gin
│ │ │ ├── wercker.yml
│ │ │ ├── codecov.yml
│ │ │ ├── doc.go
│ │ │ ├── version.go
│ │ │ ├── context_appengine.go
│ │ │ ├── response_writer_1.7.go
│ │ │ ├── test_helpers.go
│ │ │ ├── binding
│ │ │ │ ├── query.go
│ │ │ │ ├── xml.go
│ │ │ │ ├── msgpack.go
│ │ │ │ ├── protobuf.go
│ │ │ │ ├── json.go
│ │ │ │ ├── form.go
│ │ │ │ └── default_validator.go
│ │ │ ├── context_17.go
│ │ │ ├── response_writer_1.8.go
│ │ │ ├── internal
│ │ │ │ └── json
│ │ │ │ │ ├── json.go
│ │ │ │ │ └── jsoniter.go
│ │ │ ├── CONTRIBUTING.md
│ │ │ ├── render
│ │ │ │ ├── data.go
│ │ │ │ ├── xml.go
│ │ │ │ ├── json_17.go
│ │ │ │ ├── yaml.go
│ │ │ │ ├── protobuf.go
│ │ │ │ ├── redirect.go
│ │ │ │ ├── msgpack.go
│ │ │ │ ├── text.go
│ │ │ │ ├── render.go
│ │ │ │ ├── reader.go
│ │ │ │ └── html.go
│ │ │ ├── deprecated.go
│ │ │ ├── tools.go
│ │ │ ├── LICENSE
│ │ │ ├── fs.go
│ │ │ ├── go.mod
│ │ │ ├── Makefile
│ │ │ ├── mode.go
│ │ │ └── response_writer.go
│ │ └── autotls
│ │ │ ├── doc.go
│ │ │ ├── autotls.go
│ │ │ ├── LICENSE
│ │ │ └── README.md
│ ├── ugorji
│ │ └── go
│ │ │ ├── codec
│ │ │ ├── go.mod
│ │ │ ├── goversion_vendor_gte_go17.go
│ │ │ ├── goversion_vendor_lt_go15.go
│ │ │ ├── goversion_unexportedembeddedptr_gte_go110.go
│ │ │ ├── goversion_unexportedembeddedptr_lt_go110.go
│ │ │ ├── goversion_vendor_eq_go15.go
│ │ │ ├── goversion_vendor_eq_go16.go
│ │ │ ├── codecgen.go
│ │ │ ├── goversion_makemap_lt_go19.go
│ │ │ ├── goversion_arrayof_gte_go15.go
│ │ │ ├── goversion_makemap_gte_go19.go
│ │ │ ├── goversion_arrayof_lt_go15.go
│ │ │ ├── goversion_unsupported_lt_go14.go
│ │ │ ├── gen-enc-chan.go.tmpl
│ │ │ ├── fast-path.not.go
│ │ │ ├── gen-dec-map.go.tmpl
│ │ │ └── gen-dec-array.go.tmpl
│ │ │ └── LICENSE
│ ├── mattn
│ │ └── go-isatty
│ │ │ ├── doc.go
│ │ │ ├── isatty_others.go
│ │ │ ├── isatty_solaris.go
│ │ │ ├── isatty_linux.go
│ │ │ ├── isatty_bsd.go
│ │ │ ├── isatty_linux_ppc64x.go
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ └── isatty_windows.go
│ ├── thinkerou
│ │ └── favicon
│ │ │ ├── favicon.ico
│ │ │ ├── README.md
│ │ │ ├── LICENSE
│ │ │ └── favicon.go
│ ├── dustin
│ │ └── go-broadcast
│ │ │ ├── README.markdown
│ │ │ ├── LICENSE
│ │ │ └── broadcaster.go
│ ├── json-iterator
│ │ └── go
│ │ │ ├── test.sh
│ │ │ ├── build.sh
│ │ │ ├── Gopkg.lock
│ │ │ ├── Gopkg.toml
│ │ │ ├── fuzzy_mode_convert_table.md
│ │ │ ├── jsoniter.go
│ │ │ ├── pool.go
│ │ │ ├── LICENSE
│ │ │ ├── any_nil.go
│ │ │ ├── any_int64.go
│ │ │ ├── any_int32.go
│ │ │ ├── any_uint64.go
│ │ │ ├── iter_array.go
│ │ │ ├── any_uint32.go
│ │ │ ├── any_float.go
│ │ │ ├── any_invalid.go
│ │ │ ├── reflect_dynamic.go
│ │ │ ├── reflect_json_raw_message.go
│ │ │ ├── iter_skip_strict.go
│ │ │ ├── any_bool.go
│ │ │ └── stream_float.go
│ ├── gin-contrib
│ │ ├── sse
│ │ │ ├── writer.go
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ └── sse-encoder.go
│ │ └── pprof
│ │ │ ├── LICENSE
│ │ │ ├── pprof.go
│ │ │ └── README.md
│ ├── client9
│ │ └── misspell
│ │ │ ├── url.go
│ │ │ ├── Gopkg.lock
│ │ │ ├── RELEASE-HOWTO.md
│ │ │ ├── Gopkg.toml
│ │ │ ├── goreleaser.yml
│ │ │ ├── LICENSE
│ │ │ ├── case.go
│ │ │ ├── Dockerfile
│ │ │ ├── ascii.go
│ │ │ ├── legal.go
│ │ │ ├── notwords.go
│ │ │ └── Makefile
│ ├── jessevdk
│ │ └── go-assets
│ │ │ ├── assets.go
│ │ │ ├── README.md
│ │ │ ├── LICENSE
│ │ │ ├── file.go
│ │ │ └── filesystem.go
│ ├── manucorporat
│ │ └── stats
│ │ │ ├── LICENSE
│ │ │ └── stats.go
│ ├── pmezard
│ │ └── go-difflib
│ │ │ └── LICENSE
│ ├── golang
│ │ └── protobuf
│ │ │ ├── LICENSE
│ │ │ └── proto
│ │ │ └── deprecated.go
│ └── campoy
│ │ └── embedmd
│ │ └── embedmd
│ │ ├── content.go
│ │ └── command.go
└── gopkg.in
│ ├── yaml.v2
│ ├── go.mod
│ ├── NOTICE
│ ├── writerc.go
│ └── LICENSE.libyaml
│ └── go-playground
│ └── validator.v8
│ ├── logo.png
│ └── LICENSE
├── .gitignore
├── controllers
└── base_index.go
├── common
├── variables.go
├── common.go
└── config.go
├── conf
└── config.yml
├── router
├── router.go
└── add_router.go
├── README.md
├── LICENSE
├── system
└── config.go
└── main.go
/vendor/github.com/modern-go/reflect2/reflect2_amd64.s:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/relfect2_386.s:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/relfect2_arm.s:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/relfect2_arm64.s:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/relfect2_mipsx.s:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/relfect2_s390x.s:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/relfect2_amd64p32.s:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/relfect2_mips64x.s:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/relfect2_ppc64x.s:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/wercker.yml:
--------------------------------------------------------------------------------
1 | box: wercker/default
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/ugorji/go/codec
2 |
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # ignore
2 | logs/
3 |
4 | .idea/
5 | base-framework
6 | *.exe
7 |
8 |
9 | .DS_Store
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-isatty/doc.go:
--------------------------------------------------------------------------------
1 | // Package isatty implements interface to isatty
2 | package isatty
3 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v2/go.mod:
--------------------------------------------------------------------------------
1 | module "gopkg.in/yaml.v2"
2 |
3 | require (
4 | "gopkg.in/check.v1" v0.0.0-20161208181325-20d25e280405
5 | )
6 |
--------------------------------------------------------------------------------
/vendor/github.com/thinkerou/favicon/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itcloudy/base-framework/HEAD/vendor/github.com/thinkerou/favicon/favicon.ico
--------------------------------------------------------------------------------
/vendor/gopkg.in/go-playground/validator.v8/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itcloudy/base-framework/HEAD/vendor/gopkg.in/go-playground/validator.v8/logo.png
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/codecov.yml:
--------------------------------------------------------------------------------
1 | coverage:
2 | notify:
3 | gitter:
4 | default:
5 | url: https://webhooks.gitter.im/e/d90dcdeeab2f1e357165
6 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/go_below_17.go:
--------------------------------------------------------------------------------
1 | //+build !go1.7
2 |
3 | package reflect2
4 |
5 | import "unsafe"
6 |
7 | func resolveTypeOff(rtype unsafe.Pointer, off int32) unsafe.Pointer {
8 | return nil
9 | }
10 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/doc.go:
--------------------------------------------------------------------------------
1 | /*
2 | Package gin implements a HTTP web framework called gin.
3 |
4 | See https://gin-gonic.github.io/gin/ for more information about gin.
5 | */
6 | package gin // import "github.com/gin-gonic/gin"
7 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/go_above_17.go:
--------------------------------------------------------------------------------
1 | //+build go1.7
2 |
3 | package reflect2
4 |
5 | import "unsafe"
6 |
7 | //go:linkname resolveTypeOff reflect.resolveTypeOff
8 | func resolveTypeOff(rtype unsafe.Pointer, off int32) unsafe.Pointer
9 |
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/goversion_vendor_gte_go17.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
2 | // Use of this source code is governed by a MIT license found in the LICENSE file.
3 |
4 | // +build go1.7
5 |
6 | package codec
7 |
8 | const genCheckVendor = true
9 |
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
2 | // Use of this source code is governed by a MIT license found in the LICENSE file.
3 |
4 | // +build !go1.5
5 |
6 | package codec
7 |
8 | var genCheckVendor = false
9 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/version.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 Gin Core Team. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package gin
6 |
7 | // Version is the current gin framework's version.
8 | const Version = "v1.4.0-dev"
9 |
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_gte_go110.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
2 | // Use of this source code is governed by a MIT license found in the LICENSE file.
3 |
4 | // +build go1.10
5 |
6 | package codec
7 |
8 | const allowSetUnexportedEmbeddedPtr = false
9 |
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_lt_go110.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
2 | // Use of this source code is governed by a MIT license found in the LICENSE file.
3 |
4 | // +build !go1.10
5 |
6 | package codec
7 |
8 | const allowSetUnexportedEmbeddedPtr = true
9 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/concurrent/go_above_19.go:
--------------------------------------------------------------------------------
1 | //+build go1.9
2 |
3 | package concurrent
4 |
5 | import "sync"
6 |
7 | // Map is a wrapper for sync.Map introduced in go1.9
8 | type Map struct {
9 | sync.Map
10 | }
11 |
12 | // NewMap creates a thread safe Map
13 | func NewMap() *Map {
14 | return &Map{}
15 | }
16 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/context_appengine.go:
--------------------------------------------------------------------------------
1 | // +build appengine
2 |
3 | // Copyright 2017 Manu Martinez-Almeida. All rights reserved.
4 | // Use of this source code is governed by a MIT style
5 | // license that can be found in the LICENSE file.
6 |
7 | package gin
8 |
9 | func init() {
10 | defaultAppEngine = true
11 | }
12 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/go_below_19.go:
--------------------------------------------------------------------------------
1 | //+build !go1.9
2 |
3 | package reflect2
4 |
5 | import (
6 | "unsafe"
7 | )
8 |
9 | //go:linkname makemap reflect.makemap
10 | func makemap(rtype unsafe.Pointer) (m unsafe.Pointer)
11 |
12 | func makeMapWithSize(rtype unsafe.Pointer, cap int) unsafe.Pointer {
13 | return makemap(rtype)
14 | }
15 |
--------------------------------------------------------------------------------
/controllers/base_index.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 cloudy 272685110@qq.com. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 | package controllers
5 |
6 | import "github.com/gin-gonic/gin"
7 |
8 | func IndexGet(c *gin.Context) {
9 |
10 | c.Writer.Write([]byte("ok"))
11 | }
12 |
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go15.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
2 | // Use of this source code is governed by a MIT license found in the LICENSE file.
3 |
4 | // +build go1.5,!go1.6
5 |
6 | package codec
7 |
8 | import "os"
9 |
10 | var genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") == "1"
11 |
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go16.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
2 | // Use of this source code is governed by a MIT license found in the LICENSE file.
3 |
4 | // +build go1.6,!go1.7
5 |
6 | package codec
7 |
8 | import "os"
9 |
10 | var genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") != "0"
11 |
--------------------------------------------------------------------------------
/vendor/github.com/dustin/go-broadcast/README.markdown:
--------------------------------------------------------------------------------
1 | pubsubbing channels.
2 |
3 | This project primarily exists because I've been copying and pasting
4 | the exact same two files into numerous projects. It does work well,
5 | though.
6 |
7 | See [the documentation][doc] for usage and examples.
8 |
9 |
10 | [doc]: https://godoc.org/github.com/dustin/go-broadcast
11 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/response_writer_1.7.go:
--------------------------------------------------------------------------------
1 | // +build !go1.8
2 |
3 | // Copyright 2018 Gin Core Team. All rights reserved.
4 | // Use of this source code is governed by a MIT style
5 | // license that can be found in the LICENSE file.
6 |
7 | package gin
8 |
9 | // ResponseWriter ...
10 | type ResponseWriter interface {
11 | responseWriterBase
12 | }
13 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/go_above_19.go:
--------------------------------------------------------------------------------
1 | //+build go1.9
2 |
3 | package reflect2
4 |
5 | import (
6 | "unsafe"
7 | )
8 |
9 | //go:linkname makemap reflect.makemap
10 | func makemap(rtype unsafe.Pointer, cap int) (m unsafe.Pointer)
11 |
12 | func makeMapWithSize(rtype unsafe.Pointer, cap int) unsafe.Pointer {
13 | return makemap(rtype, cap)
14 | }
15 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | echo "" > coverage.txt
5 |
6 | for d in $(go list ./... | grep -v vendor); do
7 | go test -coverprofile=profile.out -coverpkg=github.com/json-iterator/go $d
8 | if [ -f profile.out ]; then
9 | cat profile.out >> coverage.txt
10 | rm profile.out
11 | fi
12 | done
13 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/concurrent/test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | echo "" > coverage.txt
5 |
6 | for d in $(go list ./... | grep -v vendor); do
7 | go test -coverprofile=profile.out -coverpkg=github.com/modern-go/concurrent $d
8 | if [ -f profile.out ]; then
9 | cat profile.out >> coverage.txt
10 | rm profile.out
11 | fi
12 | done
13 |
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/codecgen.go:
--------------------------------------------------------------------------------
1 | // +build codecgen generated
2 |
3 | package codec
4 |
5 | // this file is here, to set the codecgen variable to true
6 | // when the build tag codecgen is set.
7 | //
8 | // this allows us do specific things e.g. skip missing fields tests,
9 | // when running in codecgen mode.
10 |
11 | func init() {
12 | codecgen = true
13 | }
14 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/concurrent/log.go:
--------------------------------------------------------------------------------
1 | package concurrent
2 |
3 | import (
4 | "os"
5 | "log"
6 | "io/ioutil"
7 | )
8 |
9 | // ErrorLogger is used to print out error, can be set to writer other than stderr
10 | var ErrorLogger = log.New(os.Stderr, "", 0)
11 |
12 | // InfoLogger is used to print informational message, default to off
13 | var InfoLogger = log.New(ioutil.Discard, "", 0)
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
2 | // Use of this source code is governed by a MIT license found in the LICENSE file.
3 |
4 | // +build !go1.9
5 |
6 | package codec
7 |
8 | import "reflect"
9 |
10 | func makeMapReflect(t reflect.Type, size int) reflect.Value {
11 | return reflect.MakeMap(t)
12 | }
13 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | echo "" > coverage.txt
5 |
6 | for d in $(go list github.com/modern-go/reflect2-tests/... | grep -v vendor); do
7 | go test -coverprofile=profile.out -coverpkg=github.com/modern-go/reflect2 $d
8 | if [ -f profile.out ]; then
9 | cat profile.out >> coverage.txt
10 | rm profile.out
11 | fi
12 | done
13 |
--------------------------------------------------------------------------------
/common/variables.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 cloudy 272685110@qq.com. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 | package common
5 |
6 | var (
7 | WorkSpace string // config
8 | ServerInfo *serverModel // server config information
9 | ConfigInfo *configModel // all server config information
10 | )
11 |
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/goversion_arrayof_gte_go15.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
2 | // Use of this source code is governed by a MIT license found in the LICENSE file.
3 |
4 | // +build go1.5
5 |
6 | package codec
7 |
8 | import "reflect"
9 |
10 | const reflectArrayOfSupported = true
11 |
12 | func reflectArrayOf(count int, elem reflect.Type) reflect.Type {
13 | return reflect.ArrayOf(count, elem)
14 | }
15 |
--------------------------------------------------------------------------------
/conf/config.yml:
--------------------------------------------------------------------------------
1 | # config information
2 |
3 | # server config information
4 | server:
5 | mode: debug # debug,release
6 | host: 0.0.0.0
7 | port: 8000
8 | token_expire_second: 360000
9 | enable_https: false # 后台开启https
10 | cert_file: conf/https/cert.pem # https对应的私钥
11 | key_file: conf/https/key.pem # https对应的公钥
12 | jwt_public_key_path: conf/jwt/tm.rsa.pub
13 | jwt_private_key_path: conf/jwt/tm.rsa
14 | system_static_file_path: system_statics
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 | set -x
4 |
5 | if [ ! -d /tmp/build-golang/src/github.com/json-iterator ]; then
6 | mkdir -p /tmp/build-golang/src/github.com/json-iterator
7 | ln -s $PWD /tmp/build-golang/src/github.com/json-iterator/go
8 | fi
9 | export GOPATH=/tmp/build-golang
10 | go get -u github.com/golang/dep/cmd/dep
11 | cd /tmp/build-golang/src/github.com/json-iterator/go
12 | exec $GOPATH/bin/dep ensure -update
13 |
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/goversion_makemap_gte_go19.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
2 | // Use of this source code is governed by a MIT license found in the LICENSE file.
3 |
4 | // +build go1.9
5 |
6 | package codec
7 |
8 | import "reflect"
9 |
10 | func makeMapReflect(t reflect.Type, size int) reflect.Value {
11 | if size < 0 {
12 | return reflect.MakeMapWithSize(t, 4)
13 | }
14 | return reflect.MakeMapWithSize(t, size)
15 | }
16 |
--------------------------------------------------------------------------------
/router/router.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 cloudy 272685110@qq.com. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 | package router
5 |
6 | import (
7 | "github.com/gin-gonic/gin"
8 | )
9 |
10 | //InitRouter router init
11 | func InitRouter() *gin.Engine {
12 |
13 | router := gin.Default()
14 |
15 | router.Use(gin.Recovery())
16 | // add routers
17 | addRouter(router)
18 | return router
19 | }
20 |
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/goversion_arrayof_lt_go15.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
2 | // Use of this source code is governed by a MIT license found in the LICENSE file.
3 |
4 | // +build !go1.5
5 |
6 | package codec
7 |
8 | import "reflect"
9 |
10 | const reflectArrayOfSupported = false
11 |
12 | func reflectArrayOf(count int, elem reflect.Type) reflect.Type {
13 | panic("codec: reflect.ArrayOf unsupported in this go version")
14 | }
15 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/test_helpers.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package gin
6 |
7 | import "net/http"
8 |
9 | // CreateTestContext returns a fresh engine and context for testing purposes
10 | func CreateTestContext(w http.ResponseWriter) (c *Context, r *Engine) {
11 | r = New()
12 | c = r.allocateContext()
13 | c.reset()
14 | c.writermem.reset(w)
15 | return
16 | }
17 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-isatty/isatty_others.go:
--------------------------------------------------------------------------------
1 | // +build appengine js
2 |
3 | package isatty
4 |
5 | // IsTerminal returns true if the file descriptor is terminal which
6 | // is always false on js and appengine classic which is a sandboxed PaaS.
7 | func IsTerminal(fd uintptr) bool {
8 | return false
9 | }
10 |
11 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
12 | // terminal. This is also always false on this environment.
13 | func IsCygwinTerminal(fd uintptr) bool {
14 | return false
15 | }
16 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-contrib/sse/writer.go:
--------------------------------------------------------------------------------
1 | package sse
2 |
3 | import "io"
4 |
5 | type stringWriter interface {
6 | io.Writer
7 | WriteString(string) (int, error)
8 | }
9 |
10 | type stringWrapper struct {
11 | io.Writer
12 | }
13 |
14 | func (w stringWrapper) WriteString(str string) (int, error) {
15 | return w.Writer.Write([]byte(str))
16 | }
17 |
18 | func checkWriter(writer io.Writer) stringWriter {
19 | if w, ok := writer.(stringWriter); ok {
20 | return w
21 | } else {
22 | return stringWrapper{writer}
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/Gopkg.lock:
--------------------------------------------------------------------------------
1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
2 |
3 |
4 | [[projects]]
5 | name = "github.com/modern-go/concurrent"
6 | packages = ["."]
7 | revision = "e0a39a4cb4216ea8db28e22a69f4ec25610d513a"
8 | version = "1.0.0"
9 |
10 | [solve-meta]
11 | analyzer-name = "dep"
12 | analyzer-version = 1
13 | inputs-digest = "daee8a88b3498b61c5640056665b8b9eea062006f5e596bbb6a3ed9119a11ec7"
14 | solver-name = "gps-cdcl"
15 | solver-version = 1
16 |
--------------------------------------------------------------------------------
/router/add_router.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 cloudy 272685110@qq.com. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 | package router
5 |
6 | import (
7 | "github.com/gin-contrib/pprof"
8 | "github.com/gin-gonic/gin"
9 | "github.com/itcloudy/base-framework/controllers"
10 | )
11 |
12 | func addRouter(router *gin.Engine) {
13 | // TODO: only admin user can access pprof router
14 | pprof.Register(router, "dev/pprof")
15 | {
16 | router.GET("/", controllers.IndexGet)
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/autotls/doc.go:
--------------------------------------------------------------------------------
1 | // Package autotls support Let's Encrypt for a Go server application.
2 | //
3 | // package main
4 | //
5 | // import (
6 | // "log"
7 | //
8 | // "github.com/gin-gonic/autotls"
9 | // "github.com/gin-gonic/gin"
10 | // )
11 | //
12 | // func main() {
13 | // r := gin.Default()
14 | //
15 | // // Ping handler
16 | // r.GET("/ping", func(c *gin.Context) {
17 | // c.String(200, "pong")
18 | // })
19 | //
20 | // log.Fatal(autotls.Run(r, "example1.com", "example2.com"))
21 | // }
22 | //
23 | package autotls
24 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/binding/query.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package binding
6 |
7 | import "net/http"
8 |
9 | type queryBinding struct{}
10 |
11 | func (queryBinding) Name() string {
12 | return "query"
13 | }
14 |
15 | func (queryBinding) Bind(req *http.Request, obj interface{}) error {
16 | values := req.URL.Query()
17 | if err := mapForm(obj, values); err != nil {
18 | return err
19 | }
20 | return validate(obj)
21 | }
22 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/context_17.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 Gin Core Team. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build go1.7
6 |
7 | package gin
8 |
9 | import (
10 | "github.com/gin-gonic/gin/render"
11 | )
12 |
13 | // PureJSON serializes the given struct as JSON into the response body.
14 | // PureJSON, unlike JSON, does not replace special html characters with their unicode entities.
15 | func (c *Context) PureJSON(code int, obj interface{}) {
16 | c.Render(code, render.PureJSON{Data: obj})
17 | }
18 |
--------------------------------------------------------------------------------
/vendor/github.com/client9/misspell/url.go:
--------------------------------------------------------------------------------
1 | package misspell
2 |
3 | import (
4 | "regexp"
5 | )
6 |
7 | // Regexp for URL https://mathiasbynens.be/demo/url-regex
8 | //
9 | // original @imme_emosol (54 chars) has trouble with dashes in hostname
10 | // @(https?|ftp)://(-\.)?([^\s/?\.#-]+\.?)+(/[^\s]*)?$@iS
11 | var reURL = regexp.MustCompile(`(?i)(https?|ftp)://(-\.)?([^\s/?\.#]+\.?)+(/[^\s]*)?`)
12 |
13 | // StripURL attemps to replace URLs with blank spaces, e.g.
14 | // "xxx http://foo.com/ yyy -> "xxx yyyy"
15 | func StripURL(s string) string {
16 | return reURL.ReplaceAllStringFunc(s, replaceWithBlanks)
17 | }
18 |
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/goversion_unsupported_lt_go14.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
2 | // Use of this source code is governed by a MIT license found in the LICENSE file.
3 |
4 | // +build !go1.4
5 |
6 | package codec
7 |
8 | // This codec package will only work for go1.4 and above.
9 | // This is for the following reasons:
10 | // - go 1.4 was released in 2014
11 | // - go runtime is written fully in go
12 | // - interface only holds pointers
13 | // - reflect.Value is stabilized as 3 words
14 |
15 | func init() {
16 | panic("codec: go 1.3 and below are not supported")
17 | }
18 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v2/NOTICE:
--------------------------------------------------------------------------------
1 | Copyright 2011-2016 Canonical Ltd.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # base-framework搭建教程
2 |
3 | 对应教程地址 [https://github.com/itcloudy/base-framework-tutorial.git](https://github.com/itcloudy/base-framework-tutorial.git)
4 |
5 |
6 | - 基于golang语言web框架gin搭建应用-01新建工程 [https://github.com/itcloudy/base-framework/tree/create-project-01](https://github.com/itcloudy/base-framework/tree/create-project-01)
7 | - 基于golang语言web框架gin搭建应用-02配置文件(yml) [https://github.com/itcloudy/base-framework/tree/add-cofig-02](https://github.com/itcloudy/base-framework/tree/add-cofig-02)
8 | - 基于golang语言web框架gin搭建应用-03增加controller[https://github.com/itcloudy/base-framework/tree/controller-03](https://github.com/itcloudy/base-framework/tree/controller-03)
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/response_writer_1.8.go:
--------------------------------------------------------------------------------
1 | // +build go1.8
2 |
3 | // Copyright 2018 Gin Core Team. All rights reserved.
4 | // Use of this source code is governed by a MIT style
5 | // license that can be found in the LICENSE file.
6 |
7 | package gin
8 |
9 | import (
10 | "net/http"
11 | )
12 |
13 | // ResponseWriter ...
14 | type ResponseWriter interface {
15 | responseWriterBase
16 | // get the http.Pusher for server push
17 | Pusher() http.Pusher
18 | }
19 |
20 | func (w *responseWriter) Pusher() (pusher http.Pusher) {
21 | if pusher, ok := w.ResponseWriter.(http.Pusher); ok {
22 | return pusher
23 | }
24 | return nil
25 | }
26 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/internal/json/json.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 Bo-Yi Wu. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !jsoniter
6 |
7 | package json
8 |
9 | import "encoding/json"
10 |
11 | var (
12 | // Marshal is exported by gin/json package.
13 | Marshal = json.Marshal
14 | // MarshalIndent is exported by gin/json package.
15 | MarshalIndent = json.MarshalIndent
16 | // NewDecoder is exported by gin/json package.
17 | NewDecoder = json.NewDecoder
18 | // NewEncoder is exported by gin/json package.
19 | NewEncoder = json.NewEncoder
20 | )
21 |
--------------------------------------------------------------------------------
/vendor/github.com/client9/misspell/Gopkg.lock:
--------------------------------------------------------------------------------
1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
2 |
3 |
4 | [[projects]]
5 | name = "github.com/gobwas/glob"
6 | packages = [
7 | ".",
8 | "compiler",
9 | "match",
10 | "syntax",
11 | "syntax/ast",
12 | "syntax/lexer",
13 | "util/runes",
14 | "util/strings"
15 | ]
16 | revision = "5ccd90ef52e1e632236f7326478d4faa74f99438"
17 | version = "v0.2.3"
18 |
19 | [solve-meta]
20 | analyzer-name = "dep"
21 | analyzer-version = 1
22 | inputs-digest = "087ea4c49358ea8258ad9edfe514cd5ce9975c889c258e5ec7b5d2b720aae113"
23 | solver-name = "gps-cdcl"
24 | solver-version = 1
25 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## Contributing
2 |
3 | - With issues:
4 | - Use the search tool before opening a new issue.
5 | - Please provide source code and commit sha if you found a bug.
6 | - Review existing issues and provide feedback or react to them.
7 |
8 | - With pull requests:
9 | - Open your pull request against `master`
10 | - Your pull request should have no more than two commits, if not you should squash them.
11 | - It should pass all tests in the available continuous integrations systems such as TravisCI.
12 | - You should add/modify tests to cover your proposed code changes.
13 | - If your pull request contains a new feature, please document it on the README.
14 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/concurrent/executor.go:
--------------------------------------------------------------------------------
1 | package concurrent
2 |
3 | import "context"
4 |
5 | // Executor replace go keyword to start a new goroutine
6 | // the goroutine should cancel itself if the context passed in has been cancelled
7 | // the goroutine started by the executor, is owned by the executor
8 | // we can cancel all executors owned by the executor just by stop the executor itself
9 | // however Executor interface does not Stop method, the one starting and owning executor
10 | // should use the concrete type of executor, instead of this interface.
11 | type Executor interface {
12 | // Go starts a new goroutine controlled by the context
13 | Go(handler func(ctx context.Context))
14 | }
15 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/Gopkg.lock:
--------------------------------------------------------------------------------
1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
2 |
3 |
4 | [[projects]]
5 | name = "github.com/modern-go/concurrent"
6 | packages = ["."]
7 | revision = "e0a39a4cb4216ea8db28e22a69f4ec25610d513a"
8 | version = "1.0.0"
9 |
10 | [[projects]]
11 | name = "github.com/modern-go/reflect2"
12 | packages = ["."]
13 | revision = "4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd"
14 | version = "1.0.1"
15 |
16 | [solve-meta]
17 | analyzer-name = "dep"
18 | analyzer-version = 1
19 | inputs-digest = "ea54a775e5a354cb015502d2e7aa4b74230fc77e894f34a838b268c25ec8eeb8"
20 | solver-name = "gps-cdcl"
21 | solver-version = 1
22 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/autotls/autotls.go:
--------------------------------------------------------------------------------
1 | package autotls
2 |
3 | import (
4 | "crypto/tls"
5 | "net/http"
6 |
7 | "golang.org/x/crypto/acme/autocert"
8 | )
9 |
10 | // Run support 1-line LetsEncrypt HTTPS servers
11 | func Run(r http.Handler, domain ...string) error {
12 | return http.Serve(autocert.NewListener(domain...), r)
13 | }
14 |
15 | // RunWithManager support custom autocert manager
16 | func RunWithManager(r http.Handler, m *autocert.Manager) error {
17 | s := &http.Server{
18 | Addr: ":https",
19 | TLSConfig: &tls.Config{GetCertificate: m.GetCertificate},
20 | Handler: r,
21 | }
22 |
23 | go http.ListenAndServe(":http", m.HTTPHandler(nil))
24 |
25 | return s.ListenAndServeTLS("", "")
26 | }
27 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-isatty/isatty_solaris.go:
--------------------------------------------------------------------------------
1 | // +build solaris
2 | // +build !appengine
3 |
4 | package isatty
5 |
6 | import (
7 | "golang.org/x/sys/unix"
8 | )
9 |
10 | // IsTerminal returns true if the given file descriptor is a terminal.
11 | // see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c
12 | func IsTerminal(fd uintptr) bool {
13 | var termio unix.Termio
14 | err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio)
15 | return err == nil
16 | }
17 |
18 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
19 | // terminal. This is also always false on this environment.
20 | func IsCygwinTerminal(fd uintptr) bool {
21 | return false
22 | }
23 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/internal/json/jsoniter.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 Bo-Yi Wu. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build jsoniter
6 |
7 | package json
8 |
9 | import "github.com/json-iterator/go"
10 |
11 | var (
12 | json = jsoniter.ConfigCompatibleWithStandardLibrary
13 | // Marshal is exported by gin/json package.
14 | Marshal = json.Marshal
15 | // MarshalIndent is exported by gin/json package.
16 | MarshalIndent = json.MarshalIndent
17 | // NewDecoder is exported by gin/json package.
18 | NewDecoder = json.NewDecoder
19 | // NewEncoder is exported by gin/json package.
20 | NewEncoder = json.NewEncoder
21 | )
22 |
--------------------------------------------------------------------------------
/vendor/github.com/client9/misspell/RELEASE-HOWTO.md:
--------------------------------------------------------------------------------
1 | # Release HOWTO
2 |
3 | since I forget.
4 |
5 |
6 | 1. Review existing tags and pick new release number
7 |
8 | ```sh
9 | git tag
10 | ```
11 |
12 | 2. Tag locally
13 |
14 | ```sh
15 | git tag -a v0.1.0 -m "First release"
16 | ```
17 |
18 | If things get screwed up, delete the tag with
19 |
20 | ```sh
21 | git tag -d v0.1.0
22 | ```
23 |
24 | 3. Test goreleaser
25 |
26 | TODO: how to install goreleaser
27 |
28 | ```sh
29 | ./scripts/goreleaser-dryrun.sh
30 | ```
31 |
32 | 4. Push
33 |
34 | ```bash
35 | git push origin v0.1.0
36 | ```
37 |
38 | 5. Verify release and edit notes. See https://github.com/client9/misspell/releases
39 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-isatty/isatty_linux.go:
--------------------------------------------------------------------------------
1 | // +build linux
2 | // +build !appengine,!ppc64,!ppc64le
3 |
4 | package isatty
5 |
6 | import (
7 | "syscall"
8 | "unsafe"
9 | )
10 |
11 | const ioctlReadTermios = syscall.TCGETS
12 |
13 | // IsTerminal return true if the file descriptor is terminal.
14 | func IsTerminal(fd uintptr) bool {
15 | var termios syscall.Termios
16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
17 | return err == 0
18 | }
19 |
20 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
21 | // terminal. This is also always false on this environment.
22 | func IsCygwinTerminal(fd uintptr) bool {
23 | return false
24 | }
25 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-isatty/isatty_bsd.go:
--------------------------------------------------------------------------------
1 | // +build darwin freebsd openbsd netbsd dragonfly
2 | // +build !appengine
3 |
4 | package isatty
5 |
6 | import (
7 | "syscall"
8 | "unsafe"
9 | )
10 |
11 | const ioctlReadTermios = syscall.TIOCGETA
12 |
13 | // IsTerminal return true if the file descriptor is terminal.
14 | func IsTerminal(fd uintptr) bool {
15 | var termios syscall.Termios
16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
17 | return err == 0
18 | }
19 |
20 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
21 | // terminal. This is also always false on this environment.
22 | func IsCygwinTerminal(fd uintptr) bool {
23 | return false
24 | }
25 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-isatty/isatty_linux_ppc64x.go:
--------------------------------------------------------------------------------
1 | // +build linux
2 | // +build ppc64 ppc64le
3 |
4 | package isatty
5 |
6 | import (
7 | "unsafe"
8 |
9 | syscall "golang.org/x/sys/unix"
10 | )
11 |
12 | const ioctlReadTermios = syscall.TCGETS
13 |
14 | // IsTerminal return true if the file descriptor is terminal.
15 | func IsTerminal(fd uintptr) bool {
16 | var termios syscall.Termios
17 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
18 | return err == 0
19 | }
20 |
21 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
22 | // terminal. This is also always false on this environment.
23 | func IsCygwinTerminal(fd uintptr) bool {
24 | return false
25 | }
26 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/render/data.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package render
6 |
7 | import "net/http"
8 |
9 | // Data contains ContentType and bytes data.
10 | type Data struct {
11 | ContentType string
12 | Data []byte
13 | }
14 |
15 | // Render (Data) writes data with custom ContentType.
16 | func (r Data) Render(w http.ResponseWriter) (err error) {
17 | r.WriteContentType(w)
18 | _, err = w.Write(r.Data)
19 | return
20 | }
21 |
22 | // WriteContentType (Data) writes custom ContentType.
23 | func (r Data) WriteContentType(w http.ResponseWriter) {
24 | writeContentType(w, []string{r.ContentType})
25 | }
26 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v2/writerc.go:
--------------------------------------------------------------------------------
1 | package yaml
2 |
3 | // Set the writer error and return false.
4 | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool {
5 | emitter.error = yaml_WRITER_ERROR
6 | emitter.problem = problem
7 | return false
8 | }
9 |
10 | // Flush the output buffer.
11 | func yaml_emitter_flush(emitter *yaml_emitter_t) bool {
12 | if emitter.write_handler == nil {
13 | panic("write handler not set")
14 | }
15 |
16 | // Check if the buffer is empty.
17 | if emitter.buffer_pos == 0 {
18 | return true
19 | }
20 |
21 | if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil {
22 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error())
23 | }
24 | emitter.buffer_pos = 0
25 | return true
26 | }
27 |
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/gen-enc-chan.go.tmpl:
--------------------------------------------------------------------------------
1 | {{.Label}}:
2 | switch timeout{{.Sfx}} := z.EncBasicHandle().ChanRecvTimeout; {
3 | case timeout{{.Sfx}} == 0: // only consume available
4 | for {
5 | select {
6 | case b{{.Sfx}} := <-{{.Chan}}:
7 | {{ .Slice }} = append({{.Slice}}, b{{.Sfx}})
8 | default:
9 | break {{.Label}}
10 | }
11 | }
12 | case timeout{{.Sfx}} > 0: // consume until timeout
13 | tt{{.Sfx}} := time.NewTimer(timeout{{.Sfx}})
14 | for {
15 | select {
16 | case b{{.Sfx}} := <-{{.Chan}}:
17 | {{.Slice}} = append({{.Slice}}, b{{.Sfx}})
18 | case <-tt{{.Sfx}}.C:
19 | // close(tt.C)
20 | break {{.Label}}
21 | }
22 | }
23 | default: // consume until close
24 | for b{{.Sfx}} := range {{.Chan}} {
25 | {{.Slice}} = append({{.Slice}}, b{{.Sfx}})
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/concurrent/go_below_19.go:
--------------------------------------------------------------------------------
1 | //+build !go1.9
2 |
3 | package concurrent
4 |
5 | import "sync"
6 |
7 | // Map implements a thread safe map for go version below 1.9 using mutex
8 | type Map struct {
9 | lock sync.RWMutex
10 | data map[interface{}]interface{}
11 | }
12 |
13 | // NewMap creates a thread safe map
14 | func NewMap() *Map {
15 | return &Map{
16 | data: make(map[interface{}]interface{}, 32),
17 | }
18 | }
19 |
20 | // Load is same as sync.Map Load
21 | func (m *Map) Load(key interface{}) (elem interface{}, found bool) {
22 | m.lock.RLock()
23 | elem, found = m.data[key]
24 | m.lock.RUnlock()
25 | return
26 | }
27 |
28 | // Load is same as sync.Map Store
29 | func (m *Map) Store(key interface{}, elem interface{}) {
30 | m.lock.Lock()
31 | m.data[key] = elem
32 | m.lock.Unlock()
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/github.com/thinkerou/favicon/README.md:
--------------------------------------------------------------------------------
1 | # Favicon Gin's middleware
2 |
3 | Gin middleware to support favicon.
4 |
5 | ## Usage
6 |
7 | ### Start using it
8 |
9 | Download and install it:
10 |
11 | ```sh
12 | $ go get github.com/thinkerou/favicon
13 | ```
14 |
15 | Import it in your code:
16 |
17 | ```go
18 | import "github.com/thinkerou/favicon"
19 | ```
20 |
21 | ### Canonical example:
22 |
23 | ```go
24 | package main
25 |
26 | import (
27 | "github.com/gin-gonic/gin"
28 | "github.com/thinkerou/favicon"
29 | )
30 |
31 | func main() {
32 | r := gin.Default()
33 | r.Use(favicon.New("./favicon.ico")) // set favicon middleware
34 |
35 | r.GET("/ping", func(c *gin.Context) {
36 | c.String(200, "Hello favicon.")
37 | })
38 |
39 | r.Run(":8080")
40 | }
41 | ```
42 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/deprecated.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package gin
6 |
7 | import (
8 | "log"
9 |
10 | "github.com/gin-gonic/gin/binding"
11 | )
12 |
13 | // BindWith binds the passed struct pointer using the specified binding engine.
14 | // See the binding package.
15 | func (c *Context) BindWith(obj interface{}, b binding.Binding) error {
16 | log.Println(`BindWith(\"interface{}, binding.Binding\") error is going to
17 | be deprecated, please check issue #662 and either use MustBindWith() if you
18 | want HTTP 400 to be automatically returned if any error occur, or use
19 | ShouldBindWith() if you need to manage the error.`)
20 | return c.MustBindWith(obj, b)
21 | }
22 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/Gopkg.toml:
--------------------------------------------------------------------------------
1 | # Gopkg.toml example
2 | #
3 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
4 | # for detailed Gopkg.toml documentation.
5 | #
6 | # required = ["github.com/user/thing/cmd/thing"]
7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
8 | #
9 | # [[constraint]]
10 | # name = "github.com/user/project"
11 | # version = "1.0.0"
12 | #
13 | # [[constraint]]
14 | # name = "github.com/user/project2"
15 | # branch = "dev"
16 | # source = "github.com/myfork/project2"
17 | #
18 | # [[override]]
19 | # name = "github.com/x/y"
20 | # version = "2.4.0"
21 |
22 | ignored = ["github.com/davecgh/go-spew*","github.com/google/gofuzz*","github.com/stretchr/testify*"]
23 |
24 | [[constraint]]
25 | name = "github.com/modern-go/reflect2"
26 | version = "1.0.1"
27 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/binding/xml.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package binding
6 |
7 | import (
8 | "bytes"
9 | "encoding/xml"
10 | "io"
11 | "net/http"
12 | )
13 |
14 | type xmlBinding struct{}
15 |
16 | func (xmlBinding) Name() string {
17 | return "xml"
18 | }
19 |
20 | func (xmlBinding) Bind(req *http.Request, obj interface{}) error {
21 | return decodeXML(req.Body, obj)
22 | }
23 |
24 | func (xmlBinding) BindBody(body []byte, obj interface{}) error {
25 | return decodeXML(bytes.NewReader(body), obj)
26 | }
27 | func decodeXML(r io.Reader, obj interface{}) error {
28 | decoder := xml.NewDecoder(r)
29 | if err := decoder.Decode(obj); err != nil {
30 | return err
31 | }
32 | return validate(obj)
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/render/xml.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package render
6 |
7 | import (
8 | "encoding/xml"
9 | "net/http"
10 | )
11 |
12 | // XML contains the given interface object.
13 | type XML struct {
14 | Data interface{}
15 | }
16 |
17 | var xmlContentType = []string{"application/xml; charset=utf-8"}
18 |
19 | // Render (XML) encodes the given interface object and writes data with custom ContentType.
20 | func (r XML) Render(w http.ResponseWriter) error {
21 | r.WriteContentType(w)
22 | return xml.NewEncoder(w).Encode(r.Data)
23 | }
24 |
25 | // WriteContentType (XML) writes XML ContentType for response.
26 | func (r XML) WriteContentType(w http.ResponseWriter) {
27 | writeContentType(w, xmlContentType)
28 | }
29 |
--------------------------------------------------------------------------------
/vendor/github.com/client9/misspell/Gopkg.toml:
--------------------------------------------------------------------------------
1 | # Gopkg.toml example
2 | #
3 | # Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
4 | # for detailed Gopkg.toml documentation.
5 | #
6 | # required = ["github.com/user/thing/cmd/thing"]
7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
8 | #
9 | # [[constraint]]
10 | # name = "github.com/user/project"
11 | # version = "1.0.0"
12 | #
13 | # [[constraint]]
14 | # name = "github.com/user/project2"
15 | # branch = "dev"
16 | # source = "github.com/myfork/project2"
17 | #
18 | # [[override]]
19 | # name = "github.com/x/y"
20 | # version = "2.4.0"
21 | #
22 | # [prune]
23 | # non-go = false
24 | # go-tests = true
25 | # unused-packages = true
26 |
27 |
28 | [[constraint]]
29 | name = "github.com/gobwas/glob"
30 | version = "0.2.3"
31 |
32 | [prune]
33 | go-tests = true
34 | unused-packages = true
35 |
--------------------------------------------------------------------------------
/vendor/github.com/client9/misspell/goreleaser.yml:
--------------------------------------------------------------------------------
1 | # goreleaser.yml
2 | # https://github.com/goreleaser/goreleaser
3 |
4 | project_name: misspell
5 |
6 | builds:
7 | -
8 | main: cmd/misspell/main.go
9 | binary: misspell
10 | ldflags: -s -w -X main.version={{.Version}}
11 | goos:
12 | - darwin
13 | - linux
14 | - windows
15 | goarch:
16 | - amd64
17 | env:
18 | - CGO_ENABLED=0
19 | ignore:
20 | - goos: darwin
21 | goarch: 386
22 | - goos: windows
23 | goarch: 386
24 |
25 | archive:
26 | name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
27 | replacements:
28 | amd64: 64bit
29 | 386: 32bit
30 | darwin: mac
31 | files:
32 | - none*
33 |
34 | checksum:
35 | name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"
36 |
37 | snapshot:
38 | name_template: "SNAPSHOT-{{.Commit}}"
39 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/tools.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 Gin Core Team. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build tools
6 |
7 | // This file exists to cause `go mod` and `go get` to believe these tools
8 | // are dependencies, even though they are not runtime dependencies of any
9 | // gin package. This means they will appear in `go.mod` file, but will not
10 | // be a part of the build.
11 |
12 | package gin
13 |
14 | import (
15 | _ "github.com/campoy/embedmd"
16 | _ "github.com/client9/misspell/cmd/misspell"
17 | _ "github.com/dustin/go-broadcast"
18 | _ "github.com/gin-gonic/autotls"
19 | _ "github.com/jessevdk/go-assets"
20 | _ "github.com/manucorporat/stats"
21 | _ "github.com/thinkerou/favicon"
22 | _ "golang.org/x/crypto/acme/autocert"
23 | _ "golang.org/x/lint/golint"
24 | _ "google.golang.org/grpc"
25 | )
26 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/Gopkg.toml:
--------------------------------------------------------------------------------
1 | # Gopkg.toml example
2 | #
3 | # Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
4 | # for detailed Gopkg.toml documentation.
5 | #
6 | # required = ["github.com/user/thing/cmd/thing"]
7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
8 | #
9 | # [[constraint]]
10 | # name = "github.com/user/project"
11 | # version = "1.0.0"
12 | #
13 | # [[constraint]]
14 | # name = "github.com/user/project2"
15 | # branch = "dev"
16 | # source = "github.com/myfork/project2"
17 | #
18 | # [[override]]
19 | # name = "github.com/x/y"
20 | # version = "2.4.0"
21 | #
22 | # [prune]
23 | # non-go = false
24 | # go-tests = true
25 | # unused-packages = true
26 |
27 | ignored = []
28 |
29 | [[constraint]]
30 | name = "github.com/modern-go/concurrent"
31 | version = "1.0.0"
32 |
33 | [prune]
34 | go-tests = true
35 | unused-packages = true
36 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/render/json_17.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 Gin Core Team. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build go1.7
6 |
7 | package render
8 |
9 | import (
10 | "net/http"
11 |
12 | "github.com/gin-gonic/gin/internal/json"
13 | )
14 |
15 | // PureJSON contains the given interface object.
16 | type PureJSON struct {
17 | Data interface{}
18 | }
19 |
20 | // Render (PureJSON) writes custom ContentType and encodes the given interface object.
21 | func (r PureJSON) Render(w http.ResponseWriter) error {
22 | r.WriteContentType(w)
23 | encoder := json.NewEncoder(w)
24 | encoder.SetEscapeHTML(false)
25 | return encoder.Encode(r.Data)
26 | }
27 |
28 | // WriteContentType (PureJSON) writes custom ContentType.
29 | func (r PureJSON) WriteContentType(w http.ResponseWriter) {
30 | writeContentType(w, jsonContentType)
31 | }
32 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/safe_struct.go:
--------------------------------------------------------------------------------
1 | package reflect2
2 |
3 | type safeStructType struct {
4 | safeType
5 | }
6 |
7 | func (type2 *safeStructType) FieldByName(name string) StructField {
8 | field, found := type2.Type.FieldByName(name)
9 | if !found {
10 | panic("field " + name + " not found")
11 | }
12 | return &safeField{StructField: field}
13 | }
14 |
15 | func (type2 *safeStructType) Field(i int) StructField {
16 | return &safeField{StructField: type2.Type.Field(i)}
17 | }
18 |
19 | func (type2 *safeStructType) FieldByIndex(index []int) StructField {
20 | return &safeField{StructField: type2.Type.FieldByIndex(index)}
21 | }
22 |
23 | func (type2 *safeStructType) FieldByNameFunc(match func(string) bool) StructField {
24 | field, found := type2.Type.FieldByNameFunc(match)
25 | if !found {
26 | panic("field match condition not found in " + type2.Type.String())
27 | }
28 | return &safeField{StructField: field}
29 | }
30 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/binding/msgpack.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package binding
6 |
7 | import (
8 | "bytes"
9 | "io"
10 | "net/http"
11 |
12 | "github.com/ugorji/go/codec"
13 | )
14 |
15 | type msgpackBinding struct{}
16 |
17 | func (msgpackBinding) Name() string {
18 | return "msgpack"
19 | }
20 |
21 | func (msgpackBinding) Bind(req *http.Request, obj interface{}) error {
22 | return decodeMsgPack(req.Body, obj)
23 | }
24 |
25 | func (msgpackBinding) BindBody(body []byte, obj interface{}) error {
26 | return decodeMsgPack(bytes.NewReader(body), obj)
27 | }
28 |
29 | func decodeMsgPack(r io.Reader, obj interface{}) error {
30 | cdc := new(codec.MsgpackHandle)
31 | if err := codec.NewDecoder(r, cdc).Decode(&obj); err != nil {
32 | return err
33 | }
34 | return validate(obj)
35 | }
36 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/fuzzy_mode_convert_table.md:
--------------------------------------------------------------------------------
1 | | json type \ dest type | bool | int | uint | float |string|
2 | | --- | --- | --- | --- |--|--|
3 | | number | positive => true
negative => true
zero => false| 23.2 => 23
-32.1 => -32| 12.1 => 12
-12.1 => 0|as normal|same as origin|
4 | | string | empty string => false
string "0" => false
other strings => true | "123.32" => 123
"-123.4" => -123
"123.23xxxw" => 123
"abcde12" => 0
"-32.1" => -32| 13.2 => 13
-1.1 => 0 |12.1 => 12.1
-12.3 => -12.3
12.4xxa => 12.4
+1.1e2 =>110 |same as origin|
5 | | bool | true => true
false => false| true => 1
false => 0 | true => 1
false => 0 |true => 1
false => 0|true => "true"
false => "false"|
6 | | object | true | 0 | 0 |0|originnal json|
7 | | array | empty array => false
nonempty array => true| [] => 0
[1,2] => 1 | [] => 0
[1,2] => 1 |[] => 0
[1,2] => 1|original json|
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/jsoniter.go:
--------------------------------------------------------------------------------
1 | // Package jsoniter implements encoding and decoding of JSON as defined in
2 | // RFC 4627 and provides interfaces with identical syntax of standard lib encoding/json.
3 | // Converting from encoding/json to jsoniter is no more than replacing the package with jsoniter
4 | // and variable type declarations (if any).
5 | // jsoniter interfaces gives 100% compatibility with code using standard lib.
6 | //
7 | // "JSON and Go"
8 | // (https://golang.org/doc/articles/json_and_go.html)
9 | // gives a description of how Marshal/Unmarshal operate
10 | // between arbitrary or predefined json objects and bytes,
11 | // and it applies to jsoniter.Marshal/Unmarshal as well.
12 | //
13 | // Besides, jsoniter.Iterator provides a different set of interfaces
14 | // iterating given bytes/string/reader
15 | // and yielding parsed elements one by one.
16 | // This set of interfaces reads input as required and gives
17 | // better performance.
18 | package jsoniter
19 |
--------------------------------------------------------------------------------
/vendor/github.com/jessevdk/go-assets/assets.go:
--------------------------------------------------------------------------------
1 | // go-assets is a simple embedding asset generator and consumer library for go.
2 | // The main use of the library is to generate and embed small in-memory file
3 | // systems ready to be integrated in webservers or other services which have
4 | // a small amount of assets used at runtime. This is great for being able to do
5 | // single binary deployments with assets.
6 | //
7 | // The Generator type can be used to generate a go file containing an in-memory
8 | // file tree from files and directories on disk. The file data can be optionally
9 | // compressed using gzip to reduce file size. Afterwards, the generated file
10 | // can be included into your application and the assets can be directly accessed
11 | // without having to load them from disk. The generated assets variable is of
12 | // type FileSystem and implements the os.FileInfo and http.FileSystem interfaces
13 | // so that they can be directly used with http.FileHandler.
14 | package assets
15 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/render/yaml.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package render
6 |
7 | import (
8 | "net/http"
9 |
10 | "gopkg.in/yaml.v2"
11 | )
12 |
13 | // YAML contains the given interface object.
14 | type YAML struct {
15 | Data interface{}
16 | }
17 |
18 | var yamlContentType = []string{"application/x-yaml; charset=utf-8"}
19 |
20 | // Render (YAML) marshals the given interface object and writes data with custom ContentType.
21 | func (r YAML) Render(w http.ResponseWriter) error {
22 | r.WriteContentType(w)
23 |
24 | bytes, err := yaml.Marshal(r.Data)
25 | if err != nil {
26 | return err
27 | }
28 |
29 | w.Write(bytes)
30 | return nil
31 | }
32 |
33 | // WriteContentType (YAML) writes YAML ContentType for response.
34 | func (r YAML) WriteContentType(w http.ResponseWriter) {
35 | writeContentType(w, yamlContentType)
36 | }
37 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/render/protobuf.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 Gin Core Team. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package render
6 |
7 | import (
8 | "net/http"
9 |
10 | "github.com/golang/protobuf/proto"
11 | )
12 |
13 | // ProtoBuf contains the given interface object.
14 | type ProtoBuf struct {
15 | Data interface{}
16 | }
17 |
18 | var protobufContentType = []string{"application/x-protobuf"}
19 |
20 | // Render (ProtoBuf) marshals the given interface object and writes data with custom ContentType.
21 | func (r ProtoBuf) Render(w http.ResponseWriter) error {
22 | r.WriteContentType(w)
23 |
24 | bytes, err := proto.Marshal(r.Data.(proto.Message))
25 | if err != nil {
26 | return err
27 | }
28 |
29 | w.Write(bytes)
30 | return nil
31 | }
32 |
33 | // WriteContentType (ProtoBuf) writes ProtoBuf ContentType.
34 | func (r ProtoBuf) WriteContentType(w http.ResponseWriter) {
35 | writeContentType(w, protobufContentType)
36 | }
37 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/binding/protobuf.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package binding
6 |
7 | import (
8 | "io/ioutil"
9 | "net/http"
10 |
11 | "github.com/golang/protobuf/proto"
12 | )
13 |
14 | type protobufBinding struct{}
15 |
16 | func (protobufBinding) Name() string {
17 | return "protobuf"
18 | }
19 |
20 | func (b protobufBinding) Bind(req *http.Request, obj interface{}) error {
21 | buf, err := ioutil.ReadAll(req.Body)
22 | if err != nil {
23 | return err
24 | }
25 | return b.BindBody(buf, obj)
26 | }
27 |
28 | func (protobufBinding) BindBody(body []byte, obj interface{}) error {
29 | if err := proto.Unmarshal(body, obj.(proto.Message)); err != nil {
30 | return err
31 | }
32 | // Here it's same to return validate(obj), but util now we cann't add
33 | // `binding:""` to the struct which automatically generate by gen-proto
34 | return nil
35 | // return validate(obj)
36 | }
37 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/reflect2_kind.go:
--------------------------------------------------------------------------------
1 | package reflect2
2 |
3 | import (
4 | "reflect"
5 | "unsafe"
6 | )
7 |
8 | // DefaultTypeOfKind return the non aliased default type for the kind
9 | func DefaultTypeOfKind(kind reflect.Kind) Type {
10 | return kindTypes[kind]
11 | }
12 |
13 | var kindTypes = map[reflect.Kind]Type{
14 | reflect.Bool: TypeOf(true),
15 | reflect.Uint8: TypeOf(uint8(0)),
16 | reflect.Int8: TypeOf(int8(0)),
17 | reflect.Uint16: TypeOf(uint16(0)),
18 | reflect.Int16: TypeOf(int16(0)),
19 | reflect.Uint32: TypeOf(uint32(0)),
20 | reflect.Int32: TypeOf(int32(0)),
21 | reflect.Uint64: TypeOf(uint64(0)),
22 | reflect.Int64: TypeOf(int64(0)),
23 | reflect.Uint: TypeOf(uint(0)),
24 | reflect.Int: TypeOf(int(0)),
25 | reflect.Float32: TypeOf(float32(0)),
26 | reflect.Float64: TypeOf(float64(0)),
27 | reflect.Uintptr: TypeOf(uintptr(0)),
28 | reflect.String: TypeOf(""),
29 | reflect.UnsafePointer: TypeOf(unsafe.Pointer(nil)),
30 | }
31 |
--------------------------------------------------------------------------------
/common/common.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 cloudy 272685110@qq.com. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 | package common
5 |
6 | import (
7 | "bytes"
8 | "fmt"
9 | )
10 |
11 | // StringsJoin string array join
12 | func StringsJoin(strs ...string) string {
13 | var str string
14 | var b bytes.Buffer
15 | strsLen := len(strs)
16 | if strsLen == 0 {
17 | return str
18 | }
19 | for i := 0; i < strsLen; i++ {
20 | b.WriteString(strs[i])
21 | }
22 | str = b.String()
23 | return str
24 |
25 | }
26 | func Join2String(split string, strs ...interface{}) string {
27 | var str string
28 | var b bytes.Buffer
29 | strsLen := len(strs)
30 | if strsLen == 0 {
31 | return str
32 | }
33 | for i := 0; i < strsLen; i++ {
34 | var str interface{}
35 | switch str.(type) {
36 | case string:
37 | b.WriteString(str.(string))
38 | case int:
39 | b.WriteString(fmt.Sprintf("%d", str.(int)))
40 | case int64:
41 | b.WriteString(fmt.Sprintf("%d", str.(int)))
42 |
43 | }
44 | }
45 | str = b.String()
46 | return str
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/render/redirect.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package render
6 |
7 | import (
8 | "fmt"
9 | "net/http"
10 | )
11 |
12 | // Redirect contains the http request reference and redirects status code and location.
13 | type Redirect struct {
14 | Code int
15 | Request *http.Request
16 | Location string
17 | }
18 |
19 | // Render (Redirect) redirects the http request to new location and writes redirect response.
20 | func (r Redirect) Render(w http.ResponseWriter) error {
21 | // todo(thinkerou): go1.6 not support StatusPermanentRedirect(308)
22 | // when we upgrade go version we can use http.StatusPermanentRedirect
23 | if (r.Code < 300 || r.Code > 308) && r.Code != 201 {
24 | panic(fmt.Sprintf("Cannot redirect with status code %d", r.Code))
25 | }
26 | http.Redirect(w, r.Request, r.Location, r.Code)
27 | return nil
28 | }
29 |
30 | // WriteContentType (Redirect) don't write any ContentType.
31 | func (r Redirect) WriteContentType(http.ResponseWriter) {}
32 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-isatty/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) Yasuhiro MATSUMOTO
2 |
3 | MIT License (Expat)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2018 cloudy 272685110@qq.com
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/vendor/github.com/dustin/go-broadcast/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Dustin Sallings
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/vendor/github.com/thinkerou/favicon/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 田欧
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/pool.go:
--------------------------------------------------------------------------------
1 | package jsoniter
2 |
3 | import (
4 | "io"
5 | )
6 |
7 | // IteratorPool a thread safe pool of iterators with same configuration
8 | type IteratorPool interface {
9 | BorrowIterator(data []byte) *Iterator
10 | ReturnIterator(iter *Iterator)
11 | }
12 |
13 | // StreamPool a thread safe pool of streams with same configuration
14 | type StreamPool interface {
15 | BorrowStream(writer io.Writer) *Stream
16 | ReturnStream(stream *Stream)
17 | }
18 |
19 | func (cfg *frozenConfig) BorrowStream(writer io.Writer) *Stream {
20 | stream := cfg.streamPool.Get().(*Stream)
21 | stream.Reset(writer)
22 | return stream
23 | }
24 |
25 | func (cfg *frozenConfig) ReturnStream(stream *Stream) {
26 | stream.out = nil
27 | stream.Error = nil
28 | stream.Attachment = nil
29 | cfg.streamPool.Put(stream)
30 | }
31 |
32 | func (cfg *frozenConfig) BorrowIterator(data []byte) *Iterator {
33 | iter := cfg.iteratorPool.Get().(*Iterator)
34 | iter.ResetBytes(data)
35 | return iter
36 | }
37 |
38 | func (cfg *frozenConfig) ReturnIterator(iter *Iterator) {
39 | iter.Error = nil
40 | iter.Attachment = nil
41 | cfg.iteratorPool.Put(iter)
42 | }
43 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-contrib/pprof/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Gin-Gonic
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/autotls/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Gin-Gonic
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 json-iterator
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-contrib/sse/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Manuel Martínez-Almeida
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Manuel Martínez-Almeida
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/go-playground/validator.v8/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Dean Karn
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/vendor/github.com/client9/misspell/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015-2017 Nick Galbreath
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/render/msgpack.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package render
6 |
7 | import (
8 | "net/http"
9 |
10 | "github.com/ugorji/go/codec"
11 | )
12 |
13 | // MsgPack contains the given interface object.
14 | type MsgPack struct {
15 | Data interface{}
16 | }
17 |
18 | var msgpackContentType = []string{"application/msgpack; charset=utf-8"}
19 |
20 | // WriteContentType (MsgPack) writes MsgPack ContentType.
21 | func (r MsgPack) WriteContentType(w http.ResponseWriter) {
22 | writeContentType(w, msgpackContentType)
23 | }
24 |
25 | // Render (MsgPack) encodes the given interface object and writes data with custom ContentType.
26 | func (r MsgPack) Render(w http.ResponseWriter) error {
27 | return WriteMsgPack(w, r.Data)
28 | }
29 |
30 | // WriteMsgPack writes MsgPack ContentType and encodes the given interface object.
31 | func WriteMsgPack(w http.ResponseWriter, obj interface{}) error {
32 | writeContentType(w, msgpackContentType)
33 | var mh codec.MsgpackHandle
34 | return codec.NewEncoder(w, &mh).Encode(obj)
35 | }
36 |
--------------------------------------------------------------------------------
/vendor/github.com/manucorporat/stats/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Manuel Martínez-Almeida
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/system/config.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 cloudy 272685110@qq.com. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 | package system
5 |
6 | import (
7 | "fmt"
8 | "github.com/itcloudy/base-framework/common"
9 | "gopkg.in/yaml.v2"
10 | "io/ioutil"
11 | "os"
12 | "path"
13 | )
14 |
15 | //LoadConfigInformation load config information for application
16 | func LoadConfigInformation(configPath string) (err error) {
17 | var (
18 | filePath string
19 | wr string
20 | )
21 |
22 | if configPath == "" {
23 | wr, _ = os.Getwd()
24 | wr = path.Join(wr, "conf")
25 |
26 | } else {
27 | wr = configPath
28 | }
29 | common.WorkSpace = wr
30 | filePath = path.Join(common.WorkSpace, "config.yml")
31 | configData, err := ioutil.ReadFile(filePath)
32 | if err != nil {
33 | fmt.Printf(" config file read failed: %s", err)
34 | os.Exit(-1)
35 |
36 | }
37 | err = yaml.Unmarshal(configData, &common.ConfigInfo)
38 | if err != nil {
39 | fmt.Printf(" config parse failed: %s", err)
40 |
41 | os.Exit(-1)
42 | }
43 | // server information
44 | common.ServerInfo = common.ConfigInfo.Server
45 | return nil
46 | }
47 |
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2012-2015 Ugorji Nwoke.
4 | All rights reserved.
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/render/text.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package render
6 |
7 | import (
8 | "fmt"
9 | "io"
10 | "net/http"
11 | )
12 |
13 | // String contains the given interface object slice and its format.
14 | type String struct {
15 | Format string
16 | Data []interface{}
17 | }
18 |
19 | var plainContentType = []string{"text/plain; charset=utf-8"}
20 |
21 | // Render (String) writes data with custom ContentType.
22 | func (r String) Render(w http.ResponseWriter) error {
23 | WriteString(w, r.Format, r.Data)
24 | return nil
25 | }
26 |
27 | // WriteContentType (String) writes Plain ContentType.
28 | func (r String) WriteContentType(w http.ResponseWriter) {
29 | writeContentType(w, plainContentType)
30 | }
31 |
32 | // WriteString writes data according to its format and write custom ContentType.
33 | func WriteString(w http.ResponseWriter, format string, data []interface{}) {
34 | writeContentType(w, plainContentType)
35 | if len(data) > 0 {
36 | fmt.Fprintf(w, format, data...)
37 | return
38 | }
39 | io.WriteString(w, format)
40 | }
41 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/binding/json.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package binding
6 |
7 | import (
8 | "bytes"
9 | "io"
10 | "net/http"
11 |
12 | "github.com/gin-gonic/gin/internal/json"
13 | )
14 |
15 | // EnableDecoderUseNumber is used to call the UseNumber method on the JSON
16 | // Decoder instance. UseNumber causes the Decoder to unmarshal a number into an
17 | // interface{} as a Number instead of as a float64.
18 | var EnableDecoderUseNumber = false
19 |
20 | type jsonBinding struct{}
21 |
22 | func (jsonBinding) Name() string {
23 | return "json"
24 | }
25 |
26 | func (jsonBinding) Bind(req *http.Request, obj interface{}) error {
27 | return decodeJSON(req.Body, obj)
28 | }
29 |
30 | func (jsonBinding) BindBody(body []byte, obj interface{}) error {
31 | return decodeJSON(bytes.NewReader(body), obj)
32 | }
33 |
34 | func decodeJSON(r io.Reader, obj interface{}) error {
35 | decoder := json.NewDecoder(r)
36 | if EnableDecoderUseNumber {
37 | decoder.UseNumber()
38 | }
39 | if err := decoder.Decode(obj); err != nil {
40 | return err
41 | }
42 | return validate(obj)
43 | }
44 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/any_nil.go:
--------------------------------------------------------------------------------
1 | package jsoniter
2 |
3 | type nilAny struct {
4 | baseAny
5 | }
6 |
7 | func (any *nilAny) LastError() error {
8 | return nil
9 | }
10 |
11 | func (any *nilAny) ValueType() ValueType {
12 | return NilValue
13 | }
14 |
15 | func (any *nilAny) MustBeValid() Any {
16 | return any
17 | }
18 |
19 | func (any *nilAny) ToBool() bool {
20 | return false
21 | }
22 |
23 | func (any *nilAny) ToInt() int {
24 | return 0
25 | }
26 |
27 | func (any *nilAny) ToInt32() int32 {
28 | return 0
29 | }
30 |
31 | func (any *nilAny) ToInt64() int64 {
32 | return 0
33 | }
34 |
35 | func (any *nilAny) ToUint() uint {
36 | return 0
37 | }
38 |
39 | func (any *nilAny) ToUint32() uint32 {
40 | return 0
41 | }
42 |
43 | func (any *nilAny) ToUint64() uint64 {
44 | return 0
45 | }
46 |
47 | func (any *nilAny) ToFloat32() float32 {
48 | return 0
49 | }
50 |
51 | func (any *nilAny) ToFloat64() float64 {
52 | return 0
53 | }
54 |
55 | func (any *nilAny) ToString() string {
56 | return ""
57 | }
58 |
59 | func (any *nilAny) WriteTo(stream *Stream) {
60 | stream.WriteNil()
61 | }
62 |
63 | func (any *nilAny) Parse() *Iterator {
64 | return nil
65 | }
66 |
67 | func (any *nilAny) GetInterface() interface{} {
68 | return nil
69 | }
70 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/unsafe_ptr.go:
--------------------------------------------------------------------------------
1 | package reflect2
2 |
3 | import (
4 | "reflect"
5 | "unsafe"
6 | )
7 |
8 | type UnsafePtrType struct {
9 | unsafeType
10 | }
11 |
12 | func newUnsafePtrType(cfg *frozenConfig, type1 reflect.Type) *UnsafePtrType {
13 | return &UnsafePtrType{
14 | unsafeType: *newUnsafeType(cfg, type1),
15 | }
16 | }
17 |
18 | func (type2 *UnsafePtrType) IsNil(obj interface{}) bool {
19 | if obj == nil {
20 | return true
21 | }
22 | objEFace := unpackEFace(obj)
23 | assertType("Type.IsNil argument 1", type2.ptrRType, objEFace.rtype)
24 | return type2.UnsafeIsNil(objEFace.data)
25 | }
26 |
27 | func (type2 *UnsafePtrType) UnsafeIsNil(ptr unsafe.Pointer) bool {
28 | if ptr == nil {
29 | return true
30 | }
31 | return *(*unsafe.Pointer)(ptr) == nil
32 | }
33 |
34 | func (type2 *UnsafePtrType) LikePtr() bool {
35 | return true
36 | }
37 |
38 | func (type2 *UnsafePtrType) Indirect(obj interface{}) interface{} {
39 | objEFace := unpackEFace(obj)
40 | assertType("Type.Indirect argument 1", type2.ptrRType, objEFace.rtype)
41 | return type2.UnsafeIndirect(objEFace.data)
42 | }
43 |
44 | func (type2 *UnsafePtrType) UnsafeIndirect(ptr unsafe.Pointer) interface{} {
45 | return packEFace(type2.rtype, *(*unsafe.Pointer)(ptr))
46 | }
47 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/render/render.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package render
6 |
7 | import "net/http"
8 |
9 | // Render interface is to be implemented by JSON, XML, HTML, YAML and so on.
10 | type Render interface {
11 | // Render writes data with custom ContentType.
12 | Render(http.ResponseWriter) error
13 | // WriteContentType writes custom ContentType.
14 | WriteContentType(w http.ResponseWriter)
15 | }
16 |
17 | var (
18 | _ Render = JSON{}
19 | _ Render = IndentedJSON{}
20 | _ Render = SecureJSON{}
21 | _ Render = JsonpJSON{}
22 | _ Render = XML{}
23 | _ Render = String{}
24 | _ Render = Redirect{}
25 | _ Render = Data{}
26 | _ Render = HTML{}
27 | _ HTMLRender = HTMLDebug{}
28 | _ HTMLRender = HTMLProduction{}
29 | _ Render = YAML{}
30 | _ Render = MsgPack{}
31 | _ Render = Reader{}
32 | _ Render = AsciiJSON{}
33 | _ Render = ProtoBuf{}
34 | )
35 |
36 | func writeContentType(w http.ResponseWriter, value []string) {
37 | header := w.Header()
38 | if val := header["Content-Type"]; len(val) == 0 {
39 | header["Content-Type"] = value
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/vendor/github.com/thinkerou/favicon/favicon.go:
--------------------------------------------------------------------------------
1 | package favicon
2 |
3 | import (
4 | "bytes"
5 | "io/ioutil"
6 | "net/http"
7 | "os"
8 | "path/filepath"
9 |
10 | "github.com/gin-gonic/gin"
11 | )
12 |
13 | func New(path string) gin.HandlerFunc {
14 | path = filepath.FromSlash(path)
15 | if len(path) > 0 && !os.IsPathSeparator(path[0]) {
16 | wd, err := os.Getwd()
17 | if err != nil {
18 | panic(err)
19 | }
20 | path = filepath.Join(wd, path)
21 | }
22 |
23 | info, err := os.Stat(path)
24 | if err != nil || info == nil || info.IsDir() {
25 | panic("Invalid favicon path: " + path)
26 | }
27 |
28 | file, err := ioutil.ReadFile(path)
29 | if err != nil {
30 | panic(err)
31 | }
32 |
33 | reader := bytes.NewReader(file)
34 |
35 | return func(c *gin.Context) {
36 | if c.Request.RequestURI != "/favicon.ico" {
37 | return
38 | }
39 | if c.Request.Method != "GET" && c.Request.Method != "HEAD" {
40 | status := http.StatusOK
41 | if c.Request.Method != "OPTIONS" {
42 | status = http.StatusMethodNotAllowed
43 | }
44 | c.Header("Allow", "GET,HEAD,OPTIONS")
45 | c.AbortWithStatus(status)
46 | return
47 | }
48 | c.Header("Content-Type", "image/x-icon")
49 | http.ServeContent(c.Writer, c.Request, "favicon.ico", info.ModTime(), reader)
50 | return
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/main.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 cloudy 272685110@qq.com. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 | package main
5 |
6 | import (
7 | "flag"
8 | "fmt"
9 | "github.com/itcloudy/base-framework/common"
10 | "github.com/itcloudy/base-framework/router"
11 | "github.com/itcloudy/base-framework/system"
12 | "os"
13 | "path"
14 | )
15 |
16 | func main() {
17 | var err error
18 | fPath, _ := os.Getwd()
19 | fPath = path.Join(fPath, "conf")
20 | configPath := flag.String("c", fPath, "config file path")
21 | flag.Parse()
22 | err = system.LoadConfigInformation(*configPath)
23 | if err != nil {
24 | return
25 | }
26 |
27 | //router init
28 | router := router.InitRouter()
29 | server := common.ServerInfo
30 | serverInfo := common.StringsJoin(server.Host, ":", server.Port)
31 | // restart
32 | if server.EnableHttps {
33 | fmt.Println("server start https")
34 | err := router.RunTLS(serverInfo, server.CertFile, server.KeyFile)
35 |
36 | if err != nil {
37 | fmt.Println("server start failed ", err.Error())
38 | }
39 | } else {
40 | fmt.Printf("server start info: %s\n", serverInfo)
41 |
42 | err := router.Run(serverInfo)
43 | if err != nil {
44 | fmt.Println("server start failed ", err.Error())
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-isatty/README.md:
--------------------------------------------------------------------------------
1 | # go-isatty
2 |
3 | [](http://godoc.org/github.com/mattn/go-isatty)
4 | [](https://travis-ci.org/mattn/go-isatty)
5 | [](https://coveralls.io/github/mattn/go-isatty?branch=master)
6 | [](https://goreportcard.com/report/mattn/go-isatty)
7 |
8 | isatty for golang
9 |
10 | ## Usage
11 |
12 | ```go
13 | package main
14 |
15 | import (
16 | "fmt"
17 | "github.com/mattn/go-isatty"
18 | "os"
19 | )
20 |
21 | func main() {
22 | if isatty.IsTerminal(os.Stdout.Fd()) {
23 | fmt.Println("Is Terminal")
24 | } else if isatty.IsCygwinTerminal(os.Stdout.Fd()) {
25 | fmt.Println("Is Cygwin/MSYS2 Terminal")
26 | } else {
27 | fmt.Println("Is Not Terminal")
28 | }
29 | }
30 | ```
31 |
32 | ## Installation
33 |
34 | ```
35 | $ go get github.com/mattn/go-isatty
36 | ```
37 |
38 | ## License
39 |
40 | MIT
41 |
42 | ## Author
43 |
44 | Yasuhiro Matsumoto (a.k.a mattn)
45 |
46 | ## Thanks
47 |
48 | * k-takata: base idea for IsCygwinTerminal
49 |
50 | https://github.com/k-takata/go-iscygpty
51 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/fs.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package gin
6 |
7 | import (
8 | "net/http"
9 | "os"
10 | )
11 |
12 | type onlyfilesFS struct {
13 | fs http.FileSystem
14 | }
15 |
16 | type neuteredReaddirFile struct {
17 | http.File
18 | }
19 |
20 | // Dir returns a http.Filesystem that can be used by http.FileServer(). It is used internally
21 | // in router.Static().
22 | // if listDirectory == true, then it works the same as http.Dir() otherwise it returns
23 | // a filesystem that prevents http.FileServer() to list the directory files.
24 | func Dir(root string, listDirectory bool) http.FileSystem {
25 | fs := http.Dir(root)
26 | if listDirectory {
27 | return fs
28 | }
29 | return &onlyfilesFS{fs}
30 | }
31 |
32 | // Open conforms to http.Filesystem.
33 | func (fs onlyfilesFS) Open(name string) (http.File, error) {
34 | f, err := fs.fs.Open(name)
35 | if err != nil {
36 | return nil, err
37 | }
38 | return neuteredReaddirFile{f}, nil
39 | }
40 |
41 | // Readdir overrides the http.File default implementation.
42 | func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) {
43 | // this disables directory listing
44 | return nil, nil
45 | }
46 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/render/reader.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 Gin Core Team. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package render
6 |
7 | import (
8 | "io"
9 | "net/http"
10 | "strconv"
11 | )
12 |
13 | // Reader contains the IO reader and its length, and custom ContentType and other headers.
14 | type Reader struct {
15 | ContentType string
16 | ContentLength int64
17 | Reader io.Reader
18 | Headers map[string]string
19 | }
20 |
21 | // Render (Reader) writes data with custom ContentType and headers.
22 | func (r Reader) Render(w http.ResponseWriter) (err error) {
23 | r.WriteContentType(w)
24 | r.Headers["Content-Length"] = strconv.FormatInt(r.ContentLength, 10)
25 | r.writeHeaders(w, r.Headers)
26 | _, err = io.Copy(w, r.Reader)
27 | return
28 | }
29 |
30 | // WriteContentType (Reader) writes custom ContentType.
31 | func (r Reader) WriteContentType(w http.ResponseWriter) {
32 | writeContentType(w, []string{r.ContentType})
33 | }
34 |
35 | // writeHeaders writes custom Header.
36 | func (r Reader) writeHeaders(w http.ResponseWriter, headers map[string]string) {
37 | header := w.Header()
38 | for k, v := range headers {
39 | if val := header[k]; len(val) == 0 {
40 | header[k] = []string{v}
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/vendor/github.com/jessevdk/go-assets/README.md:
--------------------------------------------------------------------------------
1 | # go-assets
2 | go-assets is a simple embedding asset generator and consumer library for go.
3 | The main use of the library is to generate and embed small in-memory file
4 | systems ready to be integrated in webservers or other services which have
5 | a small amount of assets used at runtime. This is great for being able to do
6 | single binary deployments with assets.
7 |
8 | The [Generator](http://godoc.org/github.com/jessevdk/go-assets#Generator) type
9 | can be used to generate a go file containing an in-memory
10 | file tree from files and directories on disk. The file data can be optionally
11 | compressed using gzip to reduce file size. Afterwards, the generated file
12 | can be included into your application and the assets can be directly accessed
13 | without having to load them from disk. The generated assets variable is of
14 | type [FileSystem](http://godoc.org/github.com/jessevdk/go-assets#FileSystem) and
15 | implements the os.FileInfo and http.FileSystem interfaces so that they can be
16 | directly used with http.FileHandler.
17 |
18 | See also [go-assets-builder](https://github.com/jessevdk/go-assets-builder) for
19 | a simple builder program using go-assets and exposing the generator as a command
20 | line application.
21 |
22 | See for more information.
23 |
--------------------------------------------------------------------------------
/common/config.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 cloudy 272685110@qq.com. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 | package common
5 |
6 | import "time"
7 |
8 | //server config will used in file variables.go
9 | type configModel struct {
10 | Server *serverModel `yaml:"server"`
11 | }
12 |
13 | //serverModel get server information from config.yml
14 | type serverModel struct {
15 | Mode string `yaml:"mode"` // run mode
16 | Host string `yaml:"host"` // server host
17 | Port string `yaml:"port"` // server port
18 | EnableHttps bool `yaml:"enable_https"` // enable https
19 | CertFile string `yaml:"cert_file"` // cert file path
20 | KeyFile string `yaml:"key_file"` // key file path
21 | JwtPubKeyPath string `yaml:"jwt_public_key_path"` // jwt public key path
22 | JwtPriKeyPath string `yaml:"jwt_private_key_path"` // jwt private key path
23 | TokenExpireSecond time.Duration `yaml:"token_expire_second"` // token expire second
24 | SystemStaticFilePath string `yaml:"system_static_file_path"` // system static file path
25 | }
26 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v2/LICENSE.libyaml:
--------------------------------------------------------------------------------
1 | The following files were ported to Go from C files of libyaml, and thus
2 | are still covered by their original copyright and license:
3 |
4 | apic.go
5 | emitterc.go
6 | parserc.go
7 | readerc.go
8 | scannerc.go
9 | writerc.go
10 | yamlh.go
11 | yamlprivateh.go
12 |
13 | Copyright (c) 2006 Kirill Simonov
14 |
15 | Permission is hereby granted, free of charge, to any person obtaining a copy of
16 | this software and associated documentation files (the "Software"), to deal in
17 | the Software without restriction, including without limitation the rights to
18 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
19 | of the Software, and to permit persons to whom the Software is furnished to do
20 | so, subject to the following conditions:
21 |
22 | The above copyright notice and this permission notice shall be included in all
23 | copies or substantial portions of the Software.
24 |
25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 | SOFTWARE.
32 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/gin-gonic/gin
2 |
3 | require (
4 | github.com/campoy/embedmd v0.0.0-20171205015432-c59ce00e0296
5 | github.com/client9/misspell v0.3.4
6 | github.com/davecgh/go-spew v1.1.1 // indirect
7 | github.com/dustin/go-broadcast v0.0.0-20171205050544-f664265f5a66
8 | github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7
9 | github.com/gin-gonic/autotls v0.0.0-20180426091246-be87bd5ef97b
10 | github.com/golang/protobuf v1.2.0
11 | github.com/jessevdk/go-assets v0.0.0-20160921144138-4f4301a06e15
12 | github.com/json-iterator/go v1.1.5
13 | github.com/manucorporat/stats v0.0.0-20180402194714-3ba42d56d227
14 | github.com/mattn/go-isatty v0.0.4
15 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
16 | github.com/modern-go/reflect2 v1.0.1 // indirect
17 | github.com/pmezard/go-difflib v1.0.0 // indirect
18 | github.com/stretchr/testify v1.2.2
19 | github.com/thinkerou/favicon v0.1.0
20 | github.com/ugorji/go v1.1.1
21 | golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e
22 | golang.org/x/lint v0.0.0-20181011164241-5906bd5c48cd
23 | golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1
24 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
25 | golang.org/x/sys v0.0.0-20181011152604-fa43e7bc11ba // indirect
26 | google.golang.org/grpc v1.15.0
27 | gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
28 | gopkg.in/go-playground/validator.v8 v8.18.2
29 | gopkg.in/yaml.v2 v2.2.1
30 | )
31 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/any_int64.go:
--------------------------------------------------------------------------------
1 | package jsoniter
2 |
3 | import (
4 | "strconv"
5 | )
6 |
7 | type int64Any struct {
8 | baseAny
9 | val int64
10 | }
11 |
12 | func (any *int64Any) LastError() error {
13 | return nil
14 | }
15 |
16 | func (any *int64Any) ValueType() ValueType {
17 | return NumberValue
18 | }
19 |
20 | func (any *int64Any) MustBeValid() Any {
21 | return any
22 | }
23 |
24 | func (any *int64Any) ToBool() bool {
25 | return any.val != 0
26 | }
27 |
28 | func (any *int64Any) ToInt() int {
29 | return int(any.val)
30 | }
31 |
32 | func (any *int64Any) ToInt32() int32 {
33 | return int32(any.val)
34 | }
35 |
36 | func (any *int64Any) ToInt64() int64 {
37 | return any.val
38 | }
39 |
40 | func (any *int64Any) ToUint() uint {
41 | return uint(any.val)
42 | }
43 |
44 | func (any *int64Any) ToUint32() uint32 {
45 | return uint32(any.val)
46 | }
47 |
48 | func (any *int64Any) ToUint64() uint64 {
49 | return uint64(any.val)
50 | }
51 |
52 | func (any *int64Any) ToFloat32() float32 {
53 | return float32(any.val)
54 | }
55 |
56 | func (any *int64Any) ToFloat64() float64 {
57 | return float64(any.val)
58 | }
59 |
60 | func (any *int64Any) ToString() string {
61 | return strconv.FormatInt(any.val, 10)
62 | }
63 |
64 | func (any *int64Any) WriteTo(stream *Stream) {
65 | stream.WriteInt64(any.val)
66 | }
67 |
68 | func (any *int64Any) Parse() *Iterator {
69 | return nil
70 | }
71 |
72 | func (any *int64Any) GetInterface() interface{} {
73 | return any.val
74 | }
75 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/any_int32.go:
--------------------------------------------------------------------------------
1 | package jsoniter
2 |
3 | import (
4 | "strconv"
5 | )
6 |
7 | type int32Any struct {
8 | baseAny
9 | val int32
10 | }
11 |
12 | func (any *int32Any) LastError() error {
13 | return nil
14 | }
15 |
16 | func (any *int32Any) ValueType() ValueType {
17 | return NumberValue
18 | }
19 |
20 | func (any *int32Any) MustBeValid() Any {
21 | return any
22 | }
23 |
24 | func (any *int32Any) ToBool() bool {
25 | return any.val != 0
26 | }
27 |
28 | func (any *int32Any) ToInt() int {
29 | return int(any.val)
30 | }
31 |
32 | func (any *int32Any) ToInt32() int32 {
33 | return any.val
34 | }
35 |
36 | func (any *int32Any) ToInt64() int64 {
37 | return int64(any.val)
38 | }
39 |
40 | func (any *int32Any) ToUint() uint {
41 | return uint(any.val)
42 | }
43 |
44 | func (any *int32Any) ToUint32() uint32 {
45 | return uint32(any.val)
46 | }
47 |
48 | func (any *int32Any) ToUint64() uint64 {
49 | return uint64(any.val)
50 | }
51 |
52 | func (any *int32Any) ToFloat32() float32 {
53 | return float32(any.val)
54 | }
55 |
56 | func (any *int32Any) ToFloat64() float64 {
57 | return float64(any.val)
58 | }
59 |
60 | func (any *int32Any) ToString() string {
61 | return strconv.FormatInt(int64(any.val), 10)
62 | }
63 |
64 | func (any *int32Any) WriteTo(stream *Stream) {
65 | stream.WriteInt32(any.val)
66 | }
67 |
68 | func (any *int32Any) Parse() *Iterator {
69 | return nil
70 | }
71 |
72 | func (any *int32Any) GetInterface() interface{} {
73 | return any.val
74 | }
75 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/any_uint64.go:
--------------------------------------------------------------------------------
1 | package jsoniter
2 |
3 | import (
4 | "strconv"
5 | )
6 |
7 | type uint64Any struct {
8 | baseAny
9 | val uint64
10 | }
11 |
12 | func (any *uint64Any) LastError() error {
13 | return nil
14 | }
15 |
16 | func (any *uint64Any) ValueType() ValueType {
17 | return NumberValue
18 | }
19 |
20 | func (any *uint64Any) MustBeValid() Any {
21 | return any
22 | }
23 |
24 | func (any *uint64Any) ToBool() bool {
25 | return any.val != 0
26 | }
27 |
28 | func (any *uint64Any) ToInt() int {
29 | return int(any.val)
30 | }
31 |
32 | func (any *uint64Any) ToInt32() int32 {
33 | return int32(any.val)
34 | }
35 |
36 | func (any *uint64Any) ToInt64() int64 {
37 | return int64(any.val)
38 | }
39 |
40 | func (any *uint64Any) ToUint() uint {
41 | return uint(any.val)
42 | }
43 |
44 | func (any *uint64Any) ToUint32() uint32 {
45 | return uint32(any.val)
46 | }
47 |
48 | func (any *uint64Any) ToUint64() uint64 {
49 | return any.val
50 | }
51 |
52 | func (any *uint64Any) ToFloat32() float32 {
53 | return float32(any.val)
54 | }
55 |
56 | func (any *uint64Any) ToFloat64() float64 {
57 | return float64(any.val)
58 | }
59 |
60 | func (any *uint64Any) ToString() string {
61 | return strconv.FormatUint(any.val, 10)
62 | }
63 |
64 | func (any *uint64Any) WriteTo(stream *Stream) {
65 | stream.WriteUint64(any.val)
66 | }
67 |
68 | func (any *uint64Any) Parse() *Iterator {
69 | return nil
70 | }
71 |
72 | func (any *uint64Any) GetInterface() interface{} {
73 | return any.val
74 | }
75 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/iter_array.go:
--------------------------------------------------------------------------------
1 | package jsoniter
2 |
3 | // ReadArray read array element, tells if the array has more element to read.
4 | func (iter *Iterator) ReadArray() (ret bool) {
5 | c := iter.nextToken()
6 | switch c {
7 | case 'n':
8 | iter.skipThreeBytes('u', 'l', 'l')
9 | return false // null
10 | case '[':
11 | c = iter.nextToken()
12 | if c != ']' {
13 | iter.unreadByte()
14 | return true
15 | }
16 | return false
17 | case ']':
18 | return false
19 | case ',':
20 | return true
21 | default:
22 | iter.ReportError("ReadArray", "expect [ or , or ] or n, but found "+string([]byte{c}))
23 | return
24 | }
25 | }
26 |
27 | // ReadArrayCB read array with callback
28 | func (iter *Iterator) ReadArrayCB(callback func(*Iterator) bool) (ret bool) {
29 | c := iter.nextToken()
30 | if c == '[' {
31 | c = iter.nextToken()
32 | if c != ']' {
33 | iter.unreadByte()
34 | if !callback(iter) {
35 | return false
36 | }
37 | c = iter.nextToken()
38 | for c == ',' {
39 | if !callback(iter) {
40 | return false
41 | }
42 | c = iter.nextToken()
43 | }
44 | if c != ']' {
45 | iter.ReportError("ReadArrayCB", "expect ] in the end, but found "+string([]byte{c}))
46 | return false
47 | }
48 | return true
49 | }
50 | return true
51 | }
52 | if c == 'n' {
53 | iter.skipThreeBytes('u', 'l', 'l')
54 | return true // null
55 | }
56 | iter.ReportError("ReadArrayCB", "expect [ or n, but found "+string([]byte{c}))
57 | return false
58 | }
59 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/any_uint32.go:
--------------------------------------------------------------------------------
1 | package jsoniter
2 |
3 | import (
4 | "strconv"
5 | )
6 |
7 | type uint32Any struct {
8 | baseAny
9 | val uint32
10 | }
11 |
12 | func (any *uint32Any) LastError() error {
13 | return nil
14 | }
15 |
16 | func (any *uint32Any) ValueType() ValueType {
17 | return NumberValue
18 | }
19 |
20 | func (any *uint32Any) MustBeValid() Any {
21 | return any
22 | }
23 |
24 | func (any *uint32Any) ToBool() bool {
25 | return any.val != 0
26 | }
27 |
28 | func (any *uint32Any) ToInt() int {
29 | return int(any.val)
30 | }
31 |
32 | func (any *uint32Any) ToInt32() int32 {
33 | return int32(any.val)
34 | }
35 |
36 | func (any *uint32Any) ToInt64() int64 {
37 | return int64(any.val)
38 | }
39 |
40 | func (any *uint32Any) ToUint() uint {
41 | return uint(any.val)
42 | }
43 |
44 | func (any *uint32Any) ToUint32() uint32 {
45 | return any.val
46 | }
47 |
48 | func (any *uint32Any) ToUint64() uint64 {
49 | return uint64(any.val)
50 | }
51 |
52 | func (any *uint32Any) ToFloat32() float32 {
53 | return float32(any.val)
54 | }
55 |
56 | func (any *uint32Any) ToFloat64() float64 {
57 | return float64(any.val)
58 | }
59 |
60 | func (any *uint32Any) ToString() string {
61 | return strconv.FormatInt(int64(any.val), 10)
62 | }
63 |
64 | func (any *uint32Any) WriteTo(stream *Stream) {
65 | stream.WriteUint32(any.val)
66 | }
67 |
68 | func (any *uint32Any) Parse() *Iterator {
69 | return nil
70 | }
71 |
72 | func (any *uint32Any) GetInterface() interface{} {
73 | return any.val
74 | }
75 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/binding/form.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package binding
6 |
7 | import "net/http"
8 |
9 | const defaultMemory = 32 * 1024 * 1024
10 |
11 | type formBinding struct{}
12 | type formPostBinding struct{}
13 | type formMultipartBinding struct{}
14 |
15 | func (formBinding) Name() string {
16 | return "form"
17 | }
18 |
19 | func (formBinding) Bind(req *http.Request, obj interface{}) error {
20 | if err := req.ParseForm(); err != nil {
21 | return err
22 | }
23 | req.ParseMultipartForm(defaultMemory)
24 | if err := mapForm(obj, req.Form); err != nil {
25 | return err
26 | }
27 | return validate(obj)
28 | }
29 |
30 | func (formPostBinding) Name() string {
31 | return "form-urlencoded"
32 | }
33 |
34 | func (formPostBinding) Bind(req *http.Request, obj interface{}) error {
35 | if err := req.ParseForm(); err != nil {
36 | return err
37 | }
38 | if err := mapForm(obj, req.PostForm); err != nil {
39 | return err
40 | }
41 | return validate(obj)
42 | }
43 |
44 | func (formMultipartBinding) Name() string {
45 | return "multipart/form-data"
46 | }
47 |
48 | func (formMultipartBinding) Bind(req *http.Request, obj interface{}) error {
49 | if err := req.ParseMultipartForm(defaultMemory); err != nil {
50 | return err
51 | }
52 | if err := mapForm(obj, req.MultipartForm.Value); err != nil {
53 | return err
54 | }
55 | return validate(obj)
56 | }
57 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/safe_field.go:
--------------------------------------------------------------------------------
1 | package reflect2
2 |
3 | import (
4 | "reflect"
5 | "unsafe"
6 | )
7 |
8 | type safeField struct {
9 | reflect.StructField
10 | }
11 |
12 | func (field *safeField) Offset() uintptr {
13 | return field.StructField.Offset
14 | }
15 |
16 | func (field *safeField) Name() string {
17 | return field.StructField.Name
18 | }
19 |
20 | func (field *safeField) PkgPath() string {
21 | return field.StructField.PkgPath
22 | }
23 |
24 | func (field *safeField) Type() Type {
25 | panic("not implemented")
26 | }
27 |
28 | func (field *safeField) Tag() reflect.StructTag {
29 | return field.StructField.Tag
30 | }
31 |
32 | func (field *safeField) Index() []int {
33 | return field.StructField.Index
34 | }
35 |
36 | func (field *safeField) Anonymous() bool {
37 | return field.StructField.Anonymous
38 | }
39 |
40 | func (field *safeField) Set(obj interface{}, value interface{}) {
41 | val := reflect.ValueOf(obj).Elem()
42 | val.FieldByIndex(field.Index()).Set(reflect.ValueOf(value).Elem())
43 | }
44 |
45 | func (field *safeField) UnsafeSet(obj unsafe.Pointer, value unsafe.Pointer) {
46 | panic("unsafe operation is not supported")
47 | }
48 |
49 | func (field *safeField) Get(obj interface{}) interface{} {
50 | val := reflect.ValueOf(obj).Elem().FieldByIndex(field.Index())
51 | ptr := reflect.New(val.Type())
52 | ptr.Elem().Set(val)
53 | return ptr.Interface()
54 | }
55 |
56 | func (field *safeField) UnsafeGet(obj unsafe.Pointer) unsafe.Pointer {
57 | panic("does not support unsafe operation")
58 | }
59 |
--------------------------------------------------------------------------------
/vendor/github.com/pmezard/go-difflib/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013, Patrick Mezard
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are
6 | met:
7 |
8 | Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 | Redistributions in binary form must reproduce the above copyright
11 | notice, this list of conditions and the following disclaimer in the
12 | documentation and/or other materials provided with the distribution.
13 | The names of its contributors may not be used to endorse or promote
14 | products derived from this software without specific prior written
15 | permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/binding/default_validator.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package binding
6 |
7 | import (
8 | "reflect"
9 | "sync"
10 |
11 | "gopkg.in/go-playground/validator.v8"
12 | )
13 |
14 | type defaultValidator struct {
15 | once sync.Once
16 | validate *validator.Validate
17 | }
18 |
19 | var _ StructValidator = &defaultValidator{}
20 |
21 | // ValidateStruct receives any kind of type, but only performed struct or pointer to struct type.
22 | func (v *defaultValidator) ValidateStruct(obj interface{}) error {
23 | value := reflect.ValueOf(obj)
24 | valueType := value.Kind()
25 | if valueType == reflect.Ptr {
26 | valueType = value.Elem().Kind()
27 | }
28 | if valueType == reflect.Struct {
29 | v.lazyinit()
30 | if err := v.validate.Struct(obj); err != nil {
31 | return err
32 | }
33 | }
34 | return nil
35 | }
36 |
37 | // Engine returns the underlying validator engine which powers the default
38 | // Validator instance. This is useful if you want to register custom validations
39 | // or struct level validations. See validator GoDoc for more info -
40 | // https://godoc.org/gopkg.in/go-playground/validator.v8
41 | func (v *defaultValidator) Engine() interface{} {
42 | v.lazyinit()
43 | return v.validate
44 | }
45 |
46 | func (v *defaultValidator) lazyinit() {
47 | v.once.Do(func() {
48 | config := &validator.Config{TagName: "binding"}
49 | v.validate = validator.New(config)
50 | })
51 | }
52 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/unsafe_eface.go:
--------------------------------------------------------------------------------
1 | package reflect2
2 |
3 | import (
4 | "reflect"
5 | "unsafe"
6 | )
7 |
8 | type eface struct {
9 | rtype unsafe.Pointer
10 | data unsafe.Pointer
11 | }
12 |
13 | func unpackEFace(obj interface{}) *eface {
14 | return (*eface)(unsafe.Pointer(&obj))
15 | }
16 |
17 | func packEFace(rtype unsafe.Pointer, data unsafe.Pointer) interface{} {
18 | var i interface{}
19 | e := (*eface)(unsafe.Pointer(&i))
20 | e.rtype = rtype
21 | e.data = data
22 | return i
23 | }
24 |
25 | type UnsafeEFaceType struct {
26 | unsafeType
27 | }
28 |
29 | func newUnsafeEFaceType(cfg *frozenConfig, type1 reflect.Type) *UnsafeEFaceType {
30 | return &UnsafeEFaceType{
31 | unsafeType: *newUnsafeType(cfg, type1),
32 | }
33 | }
34 |
35 | func (type2 *UnsafeEFaceType) IsNil(obj interface{}) bool {
36 | if obj == nil {
37 | return true
38 | }
39 | objEFace := unpackEFace(obj)
40 | assertType("Type.IsNil argument 1", type2.ptrRType, objEFace.rtype)
41 | return type2.UnsafeIsNil(objEFace.data)
42 | }
43 |
44 | func (type2 *UnsafeEFaceType) UnsafeIsNil(ptr unsafe.Pointer) bool {
45 | if ptr == nil {
46 | return true
47 | }
48 | return unpackEFace(*(*interface{})(ptr)).data == nil
49 | }
50 |
51 | func (type2 *UnsafeEFaceType) Indirect(obj interface{}) interface{} {
52 | objEFace := unpackEFace(obj)
53 | assertType("Type.Indirect argument 1", type2.ptrRType, objEFace.rtype)
54 | return type2.UnsafeIndirect(objEFace.data)
55 | }
56 |
57 | func (type2 *UnsafeEFaceType) UnsafeIndirect(ptr unsafe.Pointer) interface{} {
58 | return *(*interface{})(ptr)
59 | }
60 |
--------------------------------------------------------------------------------
/vendor/github.com/golang/protobuf/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2010 The Go Authors. All rights reserved.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google Inc. nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
29 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/unsafe_iface.go:
--------------------------------------------------------------------------------
1 | package reflect2
2 |
3 | import (
4 | "reflect"
5 | "unsafe"
6 | )
7 |
8 | type iface struct {
9 | itab *itab
10 | data unsafe.Pointer
11 | }
12 |
13 | type itab struct {
14 | ignore unsafe.Pointer
15 | rtype unsafe.Pointer
16 | }
17 |
18 | func IFaceToEFace(ptr unsafe.Pointer) interface{} {
19 | iface := (*iface)(ptr)
20 | if iface.itab == nil {
21 | return nil
22 | }
23 | return packEFace(iface.itab.rtype, iface.data)
24 | }
25 |
26 | type UnsafeIFaceType struct {
27 | unsafeType
28 | }
29 |
30 | func newUnsafeIFaceType(cfg *frozenConfig, type1 reflect.Type) *UnsafeIFaceType {
31 | return &UnsafeIFaceType{
32 | unsafeType: *newUnsafeType(cfg, type1),
33 | }
34 | }
35 |
36 | func (type2 *UnsafeIFaceType) Indirect(obj interface{}) interface{} {
37 | objEFace := unpackEFace(obj)
38 | assertType("Type.Indirect argument 1", type2.ptrRType, objEFace.rtype)
39 | return type2.UnsafeIndirect(objEFace.data)
40 | }
41 |
42 | func (type2 *UnsafeIFaceType) UnsafeIndirect(ptr unsafe.Pointer) interface{} {
43 | return IFaceToEFace(ptr)
44 | }
45 |
46 | func (type2 *UnsafeIFaceType) IsNil(obj interface{}) bool {
47 | if obj == nil {
48 | return true
49 | }
50 | objEFace := unpackEFace(obj)
51 | assertType("Type.IsNil argument 1", type2.ptrRType, objEFace.rtype)
52 | return type2.UnsafeIsNil(objEFace.data)
53 | }
54 |
55 | func (type2 *UnsafeIFaceType) UnsafeIsNil(ptr unsafe.Pointer) bool {
56 | if ptr == nil {
57 | return true
58 | }
59 | iface := (*iface)(ptr)
60 | if iface.itab == nil {
61 | return true
62 | }
63 | return false
64 | }
65 |
--------------------------------------------------------------------------------
/vendor/github.com/client9/misspell/case.go:
--------------------------------------------------------------------------------
1 | package misspell
2 |
3 | import (
4 | "strings"
5 | )
6 |
7 | // WordCase is an enum of various word casing styles
8 | type WordCase int
9 |
10 | // Various WordCase types.. likely to be not correct
11 | const (
12 | CaseUnknown WordCase = iota
13 | CaseLower
14 | CaseUpper
15 | CaseTitle
16 | )
17 |
18 | // CaseStyle returns what case style a word is in
19 | func CaseStyle(word string) WordCase {
20 | upperCount := 0
21 | lowerCount := 0
22 |
23 | // this iterates over RUNES not BYTES
24 | for i := 0; i < len(word); i++ {
25 | ch := word[i]
26 | switch {
27 | case ch >= 'a' && ch <= 'z':
28 | lowerCount++
29 | case ch >= 'A' && ch <= 'Z':
30 | upperCount++
31 | }
32 | }
33 |
34 | switch {
35 | case upperCount != 0 && lowerCount == 0:
36 | return CaseUpper
37 | case upperCount == 0 && lowerCount != 0:
38 | return CaseLower
39 | case upperCount == 1 && lowerCount > 0 && word[0] >= 'A' && word[0] <= 'Z':
40 | return CaseTitle
41 | }
42 | return CaseUnknown
43 | }
44 |
45 | // CaseVariations returns
46 | // If AllUpper or First-Letter-Only is upcased: add the all upper case version
47 | // If AllLower, add the original, the title and upcase forms
48 | // If Mixed, return the original, and the all upcase form
49 | //
50 | func CaseVariations(word string, style WordCase) []string {
51 | switch style {
52 | case CaseLower:
53 | return []string{word, strings.ToUpper(word[0:1]) + word[1:], strings.ToUpper(word)}
54 | case CaseUpper:
55 | return []string{strings.ToUpper(word)}
56 | default:
57 | return []string{word, strings.ToUpper(word)}
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/vendor/github.com/jessevdk/go-assets/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Jesse van den Kieboom. All rights reserved.
2 | Redistribution and use in source and binary forms, with or without
3 | modification, are permitted provided that the following conditions are
4 | met:
5 |
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above
9 | copyright notice, this list of conditions and the following disclaimer
10 | in the documentation and/or other materials provided with the
11 | distribution.
12 | * Neither the name of Google Inc. nor the names of its
13 | contributors may be used to endorse or promote products derived from
14 | this software without specific prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/any_float.go:
--------------------------------------------------------------------------------
1 | package jsoniter
2 |
3 | import (
4 | "strconv"
5 | )
6 |
7 | type floatAny struct {
8 | baseAny
9 | val float64
10 | }
11 |
12 | func (any *floatAny) Parse() *Iterator {
13 | return nil
14 | }
15 |
16 | func (any *floatAny) ValueType() ValueType {
17 | return NumberValue
18 | }
19 |
20 | func (any *floatAny) MustBeValid() Any {
21 | return any
22 | }
23 |
24 | func (any *floatAny) LastError() error {
25 | return nil
26 | }
27 |
28 | func (any *floatAny) ToBool() bool {
29 | return any.ToFloat64() != 0
30 | }
31 |
32 | func (any *floatAny) ToInt() int {
33 | return int(any.val)
34 | }
35 |
36 | func (any *floatAny) ToInt32() int32 {
37 | return int32(any.val)
38 | }
39 |
40 | func (any *floatAny) ToInt64() int64 {
41 | return int64(any.val)
42 | }
43 |
44 | func (any *floatAny) ToUint() uint {
45 | if any.val > 0 {
46 | return uint(any.val)
47 | }
48 | return 0
49 | }
50 |
51 | func (any *floatAny) ToUint32() uint32 {
52 | if any.val > 0 {
53 | return uint32(any.val)
54 | }
55 | return 0
56 | }
57 |
58 | func (any *floatAny) ToUint64() uint64 {
59 | if any.val > 0 {
60 | return uint64(any.val)
61 | }
62 | return 0
63 | }
64 |
65 | func (any *floatAny) ToFloat32() float32 {
66 | return float32(any.val)
67 | }
68 |
69 | func (any *floatAny) ToFloat64() float64 {
70 | return any.val
71 | }
72 |
73 | func (any *floatAny) ToString() string {
74 | return strconv.FormatFloat(any.val, 'E', -1, 64)
75 | }
76 |
77 | func (any *floatAny) WriteTo(stream *Stream) {
78 | stream.WriteFloat64(any.val)
79 | }
80 |
81 | func (any *floatAny) GetInterface() interface{} {
82 | return any.val
83 | }
84 |
--------------------------------------------------------------------------------
/vendor/github.com/client9/misspell/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM golang:1.10.0-alpine
2 |
3 | # cache buster
4 | RUN echo 4
5 |
6 | # git is needed for "go get" below
7 | RUN apk add --no-cache git make
8 |
9 | # these are my standard testing / linting tools
10 | RUN /bin/true \
11 | && go get -u github.com/golang/dep/cmd/dep \
12 | && go get -u github.com/alecthomas/gometalinter \
13 | && gometalinter --install \
14 | && rm -rf /go/src /go/pkg
15 | #
16 | # * SCOWL word list
17 | #
18 | # Downloads
19 | # http://wordlist.aspell.net/dicts/
20 | # --> http://app.aspell.net/create
21 | #
22 |
23 | # use en_US large size
24 | # use regular size for others
25 | ENV SOURCE_US_BIG http://app.aspell.net/create?max_size=70&spelling=US&max_variant=2&diacritic=both&special=hacker&special=roman-numerals&download=wordlist&encoding=utf-8&format=inline
26 |
27 | # should be able tell difference between English variations using this
28 | ENV SOURCE_US http://app.aspell.net/create?max_size=60&spelling=US&max_variant=1&diacritic=both&download=wordlist&encoding=utf-8&format=inline
29 | ENV SOURCE_GB_ISE http://app.aspell.net/create?max_size=60&spelling=GBs&max_variant=2&diacritic=both&download=wordlist&encoding=utf-8&format=inline
30 | ENV SOURCE_GB_IZE http://app.aspell.net/create?max_size=60&spelling=GBz&max_variant=2&diacritic=both&download=wordlist&encoding=utf-8&format=inline
31 | ENV SOURCE_CA http://app.aspell.net/create?max_size=60&spelling=CA&max_variant=2&diacritic=both&download=wordlist&encoding=utf-8&format=inline
32 |
33 | RUN /bin/true \
34 | && mkdir /scowl-wl \
35 | && wget -O /scowl-wl/words-US-60.txt ${SOURCE_US} \
36 | && wget -O /scowl-wl/words-GB-ise-60.txt ${SOURCE_GB_ISE}
37 |
38 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/any_invalid.go:
--------------------------------------------------------------------------------
1 | package jsoniter
2 |
3 | import "fmt"
4 |
5 | type invalidAny struct {
6 | baseAny
7 | err error
8 | }
9 |
10 | func newInvalidAny(path []interface{}) *invalidAny {
11 | return &invalidAny{baseAny{}, fmt.Errorf("%v not found", path)}
12 | }
13 |
14 | func (any *invalidAny) LastError() error {
15 | return any.err
16 | }
17 |
18 | func (any *invalidAny) ValueType() ValueType {
19 | return InvalidValue
20 | }
21 |
22 | func (any *invalidAny) MustBeValid() Any {
23 | panic(any.err)
24 | }
25 |
26 | func (any *invalidAny) ToBool() bool {
27 | return false
28 | }
29 |
30 | func (any *invalidAny) ToInt() int {
31 | return 0
32 | }
33 |
34 | func (any *invalidAny) ToInt32() int32 {
35 | return 0
36 | }
37 |
38 | func (any *invalidAny) ToInt64() int64 {
39 | return 0
40 | }
41 |
42 | func (any *invalidAny) ToUint() uint {
43 | return 0
44 | }
45 |
46 | func (any *invalidAny) ToUint32() uint32 {
47 | return 0
48 | }
49 |
50 | func (any *invalidAny) ToUint64() uint64 {
51 | return 0
52 | }
53 |
54 | func (any *invalidAny) ToFloat32() float32 {
55 | return 0
56 | }
57 |
58 | func (any *invalidAny) ToFloat64() float64 {
59 | return 0
60 | }
61 |
62 | func (any *invalidAny) ToString() string {
63 | return ""
64 | }
65 |
66 | func (any *invalidAny) WriteTo(stream *Stream) {
67 | }
68 |
69 | func (any *invalidAny) Get(path ...interface{}) Any {
70 | if any.err == nil {
71 | return &invalidAny{baseAny{}, fmt.Errorf("get %v from invalid", path)}
72 | }
73 | return &invalidAny{baseAny{}, fmt.Errorf("%v, get %v from invalid", any.err, path)}
74 | }
75 |
76 | func (any *invalidAny) Parse() *Iterator {
77 | return nil
78 | }
79 |
80 | func (any *invalidAny) GetInterface() interface{} {
81 | return nil
82 | }
83 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/reflect_dynamic.go:
--------------------------------------------------------------------------------
1 | package jsoniter
2 |
3 | import (
4 | "github.com/modern-go/reflect2"
5 | "reflect"
6 | "unsafe"
7 | )
8 |
9 | type dynamicEncoder struct {
10 | valType reflect2.Type
11 | }
12 |
13 | func (encoder *dynamicEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
14 | obj := encoder.valType.UnsafeIndirect(ptr)
15 | stream.WriteVal(obj)
16 | }
17 |
18 | func (encoder *dynamicEncoder) IsEmpty(ptr unsafe.Pointer) bool {
19 | return encoder.valType.UnsafeIndirect(ptr) == nil
20 | }
21 |
22 | type efaceDecoder struct {
23 | }
24 |
25 | func (decoder *efaceDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
26 | pObj := (*interface{})(ptr)
27 | obj := *pObj
28 | if obj == nil {
29 | *pObj = iter.Read()
30 | return
31 | }
32 | typ := reflect2.TypeOf(obj)
33 | if typ.Kind() != reflect.Ptr {
34 | *pObj = iter.Read()
35 | return
36 | }
37 | ptrType := typ.(*reflect2.UnsafePtrType)
38 | ptrElemType := ptrType.Elem()
39 | if iter.WhatIsNext() == NilValue {
40 | if ptrElemType.Kind() != reflect.Ptr {
41 | iter.skipFourBytes('n', 'u', 'l', 'l')
42 | *pObj = nil
43 | return
44 | }
45 | }
46 | if reflect2.IsNil(obj) {
47 | obj := ptrElemType.New()
48 | iter.ReadVal(obj)
49 | *pObj = obj
50 | return
51 | }
52 | iter.ReadVal(obj)
53 | }
54 |
55 | type ifaceDecoder struct {
56 | valType *reflect2.UnsafeIFaceType
57 | }
58 |
59 | func (decoder *ifaceDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
60 | if iter.ReadNil() {
61 | decoder.valType.UnsafeSet(ptr, decoder.valType.UnsafeNew())
62 | return
63 | }
64 | obj := decoder.valType.UnsafeIndirect(ptr)
65 | if reflect2.IsNil(obj) {
66 | iter.ReportError("decode non empty interface", "can not unmarshal into nil")
67 | return
68 | }
69 | iter.ReadVal(obj)
70 | }
71 |
--------------------------------------------------------------------------------
/vendor/github.com/campoy/embedmd/embedmd/content.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 Google Inc. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | // http://www.apache.org/licenses/LICENSE-2.0
6 | //
7 | // Unless required by applicable law or agreed to writing, software distributed
8 | // under the License is distributed on a "AS IS" BASIS, WITHOUT WARRANTIES OR
9 | // CONDITIONS OF ANY KIND, either express or implied.
10 | //
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 |
14 | package embedmd
15 |
16 | import (
17 | "fmt"
18 | "io/ioutil"
19 | "net/http"
20 | "path/filepath"
21 | "strings"
22 | )
23 |
24 | // Fetcher provides an abstraction on a file system.
25 | // The Fetch function is called anytime some content needs to be fetched.
26 | // For now this includes files and URLs.
27 | // The first parameter is the base directory that could be used to resolve
28 | // relative paths. This base directory will be ignored for absolute paths,
29 | // such as URLs.
30 | type Fetcher interface {
31 | Fetch(dir, path string) ([]byte, error)
32 | }
33 |
34 | type fetcher struct{}
35 |
36 | func (fetcher) Fetch(dir, path string) ([]byte, error) {
37 | if !strings.HasPrefix(path, "http://") && !strings.HasPrefix(path, "https://") {
38 | path = filepath.Join(dir, filepath.FromSlash(path))
39 | return ioutil.ReadFile(path)
40 | }
41 |
42 | res, err := http.Get(path)
43 | if err != nil {
44 | return nil, err
45 | }
46 | defer res.Body.Close()
47 | if res.StatusCode != http.StatusOK {
48 | return nil, fmt.Errorf("status %s", res.Status)
49 | }
50 | return ioutil.ReadAll(res.Body)
51 | }
52 |
--------------------------------------------------------------------------------
/vendor/github.com/client9/misspell/ascii.go:
--------------------------------------------------------------------------------
1 | package misspell
2 |
3 | // ByteToUpper converts an ascii byte to upper cases
4 | // Uses a branchless algorithm
5 | func ByteToUpper(x byte) byte {
6 | b := byte(0x80) | x
7 | c := b - byte(0x61)
8 | d := ^(b - byte(0x7b))
9 | e := (c & d) & (^x & 0x7f)
10 | return x - (e >> 2)
11 | }
12 |
13 | // ByteToLower converts an ascii byte to lower case
14 | // uses a branchless algorithm
15 | func ByteToLower(eax byte) byte {
16 | ebx := eax&byte(0x7f) + byte(0x25)
17 | ebx = ebx&byte(0x7f) + byte(0x1a)
18 | ebx = ((ebx & ^eax) >> 2) & byte(0x20)
19 | return eax + ebx
20 | }
21 |
22 | // ByteEqualFold does ascii compare, case insensitive
23 | func ByteEqualFold(a, b byte) bool {
24 | return a == b || ByteToLower(a) == ByteToLower(b)
25 | }
26 |
27 | // StringEqualFold ASCII case-insensitive comparison
28 | // golang toUpper/toLower for both bytes and strings
29 | // appears to be Unicode based which is super slow
30 | // based from https://codereview.appspot.com/5180044/patch/14007/21002
31 | func StringEqualFold(s1, s2 string) bool {
32 | if len(s1) != len(s2) {
33 | return false
34 | }
35 | for i := 0; i < len(s1); i++ {
36 | c1 := s1[i]
37 | c2 := s2[i]
38 | // c1 & c2
39 | if c1 != c2 {
40 | c1 |= 'a' - 'A'
41 | c2 |= 'a' - 'A'
42 | if c1 != c2 || c1 < 'a' || c1 > 'z' {
43 | return false
44 | }
45 | }
46 | }
47 | return true
48 | }
49 |
50 | // StringHasPrefixFold is similar to strings.HasPrefix but comparison
51 | // is done ignoring ASCII case.
52 | // /
53 | func StringHasPrefixFold(s1, s2 string) bool {
54 | // prefix is bigger than input --> false
55 | if len(s1) < len(s2) {
56 | return false
57 | }
58 | if len(s1) == len(s2) {
59 | return StringEqualFold(s1, s2)
60 | }
61 | return StringEqualFold(s1[:len(s2)], s2)
62 | }
63 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/unsafe_struct.go:
--------------------------------------------------------------------------------
1 | package reflect2
2 |
3 | import (
4 | "reflect"
5 | "unsafe"
6 | )
7 |
8 | type UnsafeStructType struct {
9 | unsafeType
10 | likePtr bool
11 | }
12 |
13 | func newUnsafeStructType(cfg *frozenConfig, type1 reflect.Type) *UnsafeStructType {
14 | return &UnsafeStructType{
15 | unsafeType: *newUnsafeType(cfg, type1),
16 | likePtr: likePtrType(type1),
17 | }
18 | }
19 |
20 | func (type2 *UnsafeStructType) LikePtr() bool {
21 | return type2.likePtr
22 | }
23 |
24 | func (type2 *UnsafeStructType) Indirect(obj interface{}) interface{} {
25 | objEFace := unpackEFace(obj)
26 | assertType("Type.Indirect argument 1", type2.ptrRType, objEFace.rtype)
27 | return type2.UnsafeIndirect(objEFace.data)
28 | }
29 |
30 | func (type2 *UnsafeStructType) UnsafeIndirect(ptr unsafe.Pointer) interface{} {
31 | if type2.likePtr {
32 | return packEFace(type2.rtype, *(*unsafe.Pointer)(ptr))
33 | }
34 | return packEFace(type2.rtype, ptr)
35 | }
36 |
37 | func (type2 *UnsafeStructType) FieldByName(name string) StructField {
38 | structField, found := type2.Type.FieldByName(name)
39 | if !found {
40 | return nil
41 | }
42 | return newUnsafeStructField(type2, structField)
43 | }
44 |
45 | func (type2 *UnsafeStructType) Field(i int) StructField {
46 | return newUnsafeStructField(type2, type2.Type.Field(i))
47 | }
48 |
49 | func (type2 *UnsafeStructType) FieldByIndex(index []int) StructField {
50 | return newUnsafeStructField(type2, type2.Type.FieldByIndex(index))
51 | }
52 |
53 | func (type2 *UnsafeStructType) FieldByNameFunc(match func(string) bool) StructField {
54 | structField, found := type2.Type.FieldByNameFunc(match)
55 | if !found {
56 | panic("field match condition not found in " + type2.Type.String())
57 | }
58 | return newUnsafeStructField(type2, structField)
59 | }
60 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-contrib/pprof/pprof.go:
--------------------------------------------------------------------------------
1 | package pprof
2 |
3 | import (
4 | "net/http"
5 | "net/http/pprof"
6 |
7 | "github.com/gin-gonic/gin"
8 | )
9 |
10 | const (
11 | // DefaultPrefix url prefix of pprof
12 | DefaultPrefix = "/debug/pprof"
13 | )
14 |
15 | func getPrefix(prefixOptions ...string) string {
16 | prefix := DefaultPrefix
17 | if len(prefixOptions) > 0 {
18 | prefix = prefixOptions[0]
19 | }
20 | return prefix
21 | }
22 |
23 | // Register the standard HandlerFuncs from the net/http/pprof package with
24 | // the provided gin.Engine. prefixOptions is a optional. If not prefixOptions,
25 | // the default path prefix is used, otherwise first prefixOptions will be path prefix.
26 | func Register(r *gin.Engine, prefixOptions ...string) {
27 | prefix := getPrefix(prefixOptions...)
28 |
29 | prefixRouter := r.Group(prefix)
30 | {
31 | prefixRouter.GET("/", pprofHandler(pprof.Index))
32 | prefixRouter.GET("/cmdline", pprofHandler(pprof.Cmdline))
33 | prefixRouter.GET("/profile", pprofHandler(pprof.Profile))
34 | prefixRouter.POST("/symbol", pprofHandler(pprof.Symbol))
35 | prefixRouter.GET("/symbol", pprofHandler(pprof.Symbol))
36 | prefixRouter.GET("/trace", pprofHandler(pprof.Trace))
37 | prefixRouter.GET("/block", pprofHandler(pprof.Handler("block").ServeHTTP))
38 | prefixRouter.GET("/goroutine", pprofHandler(pprof.Handler("goroutine").ServeHTTP))
39 | prefixRouter.GET("/heap", pprofHandler(pprof.Handler("heap").ServeHTTP))
40 | prefixRouter.GET("/mutex", pprofHandler(pprof.Handler("mutex").ServeHTTP))
41 | prefixRouter.GET("/threadcreate", pprofHandler(pprof.Handler("threadcreate").ServeHTTP))
42 | }
43 | }
44 |
45 | func pprofHandler(h http.HandlerFunc) gin.HandlerFunc {
46 | handler := http.HandlerFunc(h)
47 | return func(c *gin.Context) {
48 | handler.ServeHTTP(c.Writer, c.Request)
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/vendor/github.com/manucorporat/stats/stats.go:
--------------------------------------------------------------------------------
1 | package stats
2 |
3 | import "sync"
4 |
5 | type ValueType float64
6 | type StatsType map[string]ValueType
7 |
8 | type StatsCollector struct {
9 | lock sync.RWMutex
10 | stats StatsType
11 | }
12 |
13 | func New() *StatsCollector {
14 | s := new(StatsCollector)
15 | s.Reset()
16 | return s
17 | }
18 |
19 | func (s *StatsCollector) Reset() {
20 | s.lock.Lock()
21 | s.stats = make(StatsType)
22 | s.lock.Unlock()
23 | }
24 |
25 | func (s *StatsCollector) Set(key string, value ValueType) {
26 | s.lock.Lock()
27 | s.stats[key] = value
28 | s.lock.Unlock()
29 | }
30 |
31 | func (s *StatsCollector) Add(key string, delta ValueType) (v ValueType) {
32 | s.lock.Lock()
33 | v = s.stats[key]
34 | v += delta
35 | s.stats[key] = v
36 | s.lock.Unlock()
37 | return
38 | }
39 |
40 | func (s *StatsCollector) Get(key string) (v ValueType) {
41 | s.lock.RLock()
42 | v = s.stats[key]
43 | s.lock.RUnlock()
44 | return
45 | }
46 |
47 | func (s *StatsCollector) Del(key string) {
48 | s.lock.Lock()
49 | delete(s.stats, key)
50 | s.lock.Unlock()
51 | }
52 |
53 | func (s *StatsCollector) Data() StatsType {
54 | cp := make(StatsType)
55 | s.lock.RLock()
56 | for key, value := range s.stats {
57 | cp[key] = value
58 | }
59 | s.lock.RUnlock()
60 | return cp
61 | }
62 |
63 | var defaultCollector = New()
64 |
65 | func Reset() {
66 | defaultCollector.Reset()
67 | }
68 |
69 | func Set(key string, value ValueType) {
70 | defaultCollector.Set(key, value)
71 | }
72 |
73 | func Del(key string) {
74 | defaultCollector.Del(key)
75 | }
76 |
77 | func Add(key string, delta ValueType) ValueType {
78 | return defaultCollector.Add(key, delta)
79 | }
80 |
81 | func Get(key string) ValueType {
82 | return defaultCollector.Get(key)
83 | }
84 |
85 | func Data() StatsType {
86 | return defaultCollector.Data()
87 | }
88 |
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/fast-path.not.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
2 | // Use of this source code is governed by a MIT license found in the LICENSE file.
3 |
4 | // +build notfastpath
5 |
6 | package codec
7 |
8 | import "reflect"
9 |
10 | const fastpathEnabled = false
11 |
12 | // The generated fast-path code is very large, and adds a few seconds to the build time.
13 | // This causes test execution, execution of small tools which use codec, etc
14 | // to take a long time.
15 | //
16 | // To mitigate, we now support the notfastpath tag.
17 | // This tag disables fastpath during build, allowing for faster build, test execution,
18 | // short-program runs, etc.
19 |
20 | func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { return false }
21 | func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { return false }
22 | func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { return false }
23 | func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { return false }
24 | func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool { return false }
25 |
26 | type fastpathT struct{}
27 | type fastpathE struct {
28 | rtid uintptr
29 | rt reflect.Type
30 | encfn func(*Encoder, *codecFnInfo, reflect.Value)
31 | decfn func(*Decoder, *codecFnInfo, reflect.Value)
32 | }
33 | type fastpathA [0]fastpathE
34 |
35 | func (x fastpathA) index(rtid uintptr) int { return -1 }
36 |
37 | func (_ fastpathT) DecSliceUint8V(v []uint8, canChange bool, d *Decoder) (_ []uint8, changed bool) {
38 | fn := d.cfer().get(uint8SliceTyp, true, true)
39 | d.kSlice(&fn.i, reflect.ValueOf(&v).Elem())
40 | return v, true
41 | }
42 |
43 | var fastpathAV fastpathA
44 | var fastpathTV fastpathT
45 |
46 | // ----
47 | type TestMammoth2Wrapper struct{} // to allow testMammoth work in notfastpath mode
48 |
--------------------------------------------------------------------------------
/vendor/github.com/jessevdk/go-assets/file.go:
--------------------------------------------------------------------------------
1 | package assets
2 |
3 | import (
4 | "bytes"
5 | "os"
6 | "path"
7 | "time"
8 | )
9 |
10 | // An asset file.
11 | type File struct {
12 | // The full asset file path
13 | Path string
14 |
15 | // The asset file mode
16 | FileMode os.FileMode
17 |
18 | // The asset modification time
19 | Mtime time.Time
20 |
21 | // The asset data. Note that this data might be in gzip compressed form.
22 | Data []byte
23 |
24 | fs *FileSystem
25 | buf *bytes.Reader
26 | dirIndex int
27 | }
28 |
29 | // Implementation of os.FileInfo
30 |
31 | func (f *File) Name() string {
32 | return path.Base(f.Path)
33 | }
34 |
35 | func (f *File) Mode() os.FileMode {
36 | return f.FileMode
37 | }
38 |
39 | func (f *File) ModTime() time.Time {
40 | return f.Mtime
41 | }
42 |
43 | func (f *File) IsDir() bool {
44 | return f.FileMode.IsDir()
45 | }
46 |
47 | func (f *File) Size() int64 {
48 | return int64(len(f.Data))
49 | }
50 |
51 | func (f *File) Sys() interface{} {
52 | return nil
53 | }
54 |
55 | // Implementation of http.File
56 |
57 | func (f *File) Close() error {
58 | f.buf = nil
59 | f.dirIndex = 0
60 |
61 | return nil
62 | }
63 |
64 | func (f *File) Stat() (os.FileInfo, error) {
65 | return f, nil
66 | }
67 |
68 | func (f *File) Readdir(count int) ([]os.FileInfo, error) {
69 | if f.IsDir() {
70 | ret, err := f.fs.readDir(f.Path, f.dirIndex, count)
71 | f.dirIndex += len(ret)
72 |
73 | return ret, err
74 | } else {
75 | return nil, os.ErrInvalid
76 | }
77 | }
78 |
79 | func (f *File) Read(data []byte) (int, error) {
80 | if f.buf == nil {
81 | f.buf = bytes.NewReader(f.Data)
82 | }
83 |
84 | return f.buf.Read(data)
85 | }
86 |
87 | func (f *File) Seek(offset int64, whence int) (int64, error) {
88 | if f.buf == nil {
89 | f.buf = bytes.NewReader(f.Data)
90 | }
91 |
92 | return f.buf.Seek(offset, whence)
93 | }
94 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/reflect_json_raw_message.go:
--------------------------------------------------------------------------------
1 | package jsoniter
2 |
3 | import (
4 | "encoding/json"
5 | "github.com/modern-go/reflect2"
6 | "unsafe"
7 | )
8 |
9 | var jsonRawMessageType = reflect2.TypeOfPtr((*json.RawMessage)(nil)).Elem()
10 | var jsoniterRawMessageType = reflect2.TypeOfPtr((*RawMessage)(nil)).Elem()
11 |
12 | func createEncoderOfJsonRawMessage(ctx *ctx, typ reflect2.Type) ValEncoder {
13 | if typ == jsonRawMessageType {
14 | return &jsonRawMessageCodec{}
15 | }
16 | if typ == jsoniterRawMessageType {
17 | return &jsoniterRawMessageCodec{}
18 | }
19 | return nil
20 | }
21 |
22 | func createDecoderOfJsonRawMessage(ctx *ctx, typ reflect2.Type) ValDecoder {
23 | if typ == jsonRawMessageType {
24 | return &jsonRawMessageCodec{}
25 | }
26 | if typ == jsoniterRawMessageType {
27 | return &jsoniterRawMessageCodec{}
28 | }
29 | return nil
30 | }
31 |
32 | type jsonRawMessageCodec struct {
33 | }
34 |
35 | func (codec *jsonRawMessageCodec) Decode(ptr unsafe.Pointer, iter *Iterator) {
36 | *((*json.RawMessage)(ptr)) = json.RawMessage(iter.SkipAndReturnBytes())
37 | }
38 |
39 | func (codec *jsonRawMessageCodec) Encode(ptr unsafe.Pointer, stream *Stream) {
40 | stream.WriteRaw(string(*((*json.RawMessage)(ptr))))
41 | }
42 |
43 | func (codec *jsonRawMessageCodec) IsEmpty(ptr unsafe.Pointer) bool {
44 | return len(*((*json.RawMessage)(ptr))) == 0
45 | }
46 |
47 | type jsoniterRawMessageCodec struct {
48 | }
49 |
50 | func (codec *jsoniterRawMessageCodec) Decode(ptr unsafe.Pointer, iter *Iterator) {
51 | *((*RawMessage)(ptr)) = RawMessage(iter.SkipAndReturnBytes())
52 | }
53 |
54 | func (codec *jsoniterRawMessageCodec) Encode(ptr unsafe.Pointer, stream *Stream) {
55 | stream.WriteRaw(string(*((*RawMessage)(ptr))))
56 | }
57 |
58 | func (codec *jsoniterRawMessageCodec) IsEmpty(ptr unsafe.Pointer) bool {
59 | return len(*((*RawMessage)(ptr))) == 0
60 | }
61 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/autotls/README.md:
--------------------------------------------------------------------------------
1 | # autotls
2 |
3 | [](https://travis-ci.org/gin-gonic/autotls)
4 | [](https://goreportcard.com/report/github.com/gin-gonic/autotls)
5 | [](https://godoc.org/github.com/gin-gonic/autotls)
6 | [](https://gitter.im/gin-gonic/autotls?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
7 |
8 | Support Let's Encrypt for a Go server application.
9 |
10 | ## example
11 |
12 | example for 1-line LetsEncrypt HTTPS servers.
13 |
14 | [embedmd]:# (example/example1.go go)
15 | ```go
16 | package main
17 |
18 | import (
19 | "log"
20 |
21 | "github.com/gin-gonic/autotls"
22 | "github.com/gin-gonic/gin"
23 | )
24 |
25 | func main() {
26 | r := gin.Default()
27 |
28 | // Ping handler
29 | r.GET("/ping", func(c *gin.Context) {
30 | c.String(200, "pong")
31 | })
32 |
33 | log.Fatal(autotls.Run(r, "example1.com", "example2.com"))
34 | }
35 | ```
36 |
37 | example for custom autocert manager.
38 |
39 | [embedmd]:# (example/example2.go go)
40 | ```go
41 | package main
42 |
43 | import (
44 | "log"
45 |
46 | "github.com/gin-gonic/autotls"
47 | "github.com/gin-gonic/gin"
48 | "golang.org/x/crypto/acme/autocert"
49 | )
50 |
51 | func main() {
52 | r := gin.Default()
53 |
54 | // Ping handler
55 | r.GET("/ping", func(c *gin.Context) {
56 | c.String(200, "pong")
57 | })
58 |
59 | m := autocert.Manager{
60 | Prompt: autocert.AcceptTOS,
61 | HostPolicy: autocert.HostWhitelist("example1.com", "example2.com"),
62 | Cache: autocert.DirCache("/var/www/.cache"),
63 | }
64 |
65 | log.Fatal(autotls.RunWithManager(r, &m))
66 | }
67 | ```
68 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-contrib/sse/README.md:
--------------------------------------------------------------------------------
1 | # Server-Sent Events
2 |
3 | [](https://godoc.org/github.com/gin-contrib/sse)
4 | [](https://travis-ci.org/gin-contrib/sse)
5 | [](https://codecov.io/gh/gin-contrib/sse)
6 | [](https://goreportcard.com/report/github.com/gin-contrib/sse)
7 |
8 | Server-sent events (SSE) is a technology where a browser receives automatic updates from a server via HTTP connection. The Server-Sent Events EventSource API is [standardized as part of HTML5[1] by the W3C](http://www.w3.org/TR/2009/WD-eventsource-20091029/).
9 |
10 | - [Read this great SSE introduction by the HTML5Rocks guys](http://www.html5rocks.com/en/tutorials/eventsource/basics/)
11 | - [Browser support](http://caniuse.com/#feat=eventsource)
12 |
13 | ## Sample code
14 |
15 | ```go
16 | import "github.com/gin-contrib/sse"
17 |
18 | func httpHandler(w http.ResponseWriter, req *http.Request) {
19 | // data can be a primitive like a string, an integer or a float
20 | sse.Encode(w, sse.Event{
21 | Event: "message",
22 | Data: "some data\nmore data",
23 | })
24 |
25 | // also a complex type, like a map, a struct or a slice
26 | sse.Encode(w, sse.Event{
27 | Id: "124",
28 | Event: "message",
29 | Data: map[string]interface{}{
30 | "user": "manu",
31 | "date": time.Now().Unix(),
32 | "content": "hi!",
33 | },
34 | })
35 | }
36 | ```
37 | ```
38 | event: message
39 | data: some data\\nmore data
40 |
41 | id: 124
42 | event: message
43 | data: {"content":"hi!","date":1431540810,"user":"manu"}
44 |
45 | ```
46 |
47 | ## Content-Type
48 |
49 | ```go
50 | fmt.Println(sse.ContentType)
51 | ```
52 | ```
53 | text/event-stream
54 | ```
55 |
56 | ## Decoding support
57 |
58 | There is a client-side implementation of SSE coming soon.
59 |
--------------------------------------------------------------------------------
/vendor/github.com/golang/protobuf/proto/deprecated.go:
--------------------------------------------------------------------------------
1 | // Go support for Protocol Buffers - Google's data interchange format
2 | //
3 | // Copyright 2018 The Go Authors. All rights reserved.
4 | // https://github.com/golang/protobuf
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions are
8 | // met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following disclaimer
14 | // in the documentation and/or other materials provided with the
15 | // distribution.
16 | // * Neither the name of Google Inc. nor the names of its
17 | // contributors may be used to endorse or promote products derived from
18 | // this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 |
32 | package proto
33 |
34 | // Deprecated: do not use.
35 | type Stats struct{ Emalloc, Dmalloc, Encode, Decode, Chit, Cmiss, Size uint64 }
36 |
37 | // Deprecated: do not use.
38 | func GetStats() Stats { return Stats{} }
39 |
--------------------------------------------------------------------------------
/vendor/github.com/jessevdk/go-assets/filesystem.go:
--------------------------------------------------------------------------------
1 | package assets
2 |
3 | import (
4 | "bytes"
5 | "net/http"
6 | "os"
7 | "path"
8 | "time"
9 | )
10 |
11 | // An in-memory asset file system. The file system implements the
12 | // http.FileSystem interface.
13 | type FileSystem struct {
14 | // A map of directory paths to the files in those directories.
15 | Dirs map[string][]string
16 |
17 | // A map of file/directory paths to assets.File types.
18 | Files map[string]*File
19 |
20 | // Override loading assets from local path. Useful for development.
21 | LocalPath string
22 | }
23 |
24 | func NewFileSystem(dirs map[string][]string, files map[string]*File, localPath string) *FileSystem {
25 | fs := &FileSystem{
26 | Dirs: dirs,
27 | Files: files,
28 | LocalPath: localPath,
29 | }
30 |
31 | for _, f := range fs.Files {
32 | f.fs = fs
33 | }
34 |
35 | return fs
36 | }
37 |
38 | func (f *FileSystem) NewFile(path string, filemode os.FileMode, mtime time.Time, data []byte) *File {
39 | return &File{
40 | Path: path,
41 | FileMode: filemode,
42 | Mtime: mtime,
43 | Data: data,
44 |
45 | fs: f,
46 | }
47 | }
48 |
49 | // Implementation of http.FileSystem
50 | func (f *FileSystem) Open(p string) (http.File, error) {
51 | p = path.Clean(p)
52 |
53 | if len(f.LocalPath) != 0 {
54 | return http.Dir(f.LocalPath).Open(p)
55 | }
56 |
57 | if fi, ok := f.Files[p]; ok {
58 | if !fi.IsDir() {
59 | // Make a copy for reading
60 | ret := fi
61 | ret.buf = bytes.NewReader(ret.Data)
62 |
63 | return ret, nil
64 | }
65 |
66 | return fi, nil
67 | }
68 |
69 | return nil, os.ErrNotExist
70 | }
71 |
72 | func (f *FileSystem) readDir(p string, index int, count int) ([]os.FileInfo, error) {
73 | if d, ok := f.Dirs[p]; ok {
74 | maxl := index + count
75 |
76 | if maxl > len(d) {
77 | maxl = len(d)
78 | }
79 |
80 | ret := make([]os.FileInfo, 0, maxl-index)
81 |
82 | for i := index; i < maxl; i++ {
83 | ret = append(ret, f.Files[path.Join(p, d[i])])
84 | }
85 |
86 | return ret, nil
87 | }
88 |
89 | return nil, os.ErrNotExist
90 | }
91 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/concurrent/README.md:
--------------------------------------------------------------------------------
1 | # concurrent
2 |
3 | [](https://sourcegraph.com/github.com/modern-go/concurrent?badge)
4 | [](http://godoc.org/github.com/modern-go/concurrent)
5 | [](https://travis-ci.org/modern-go/concurrent)
6 | [](https://codecov.io/gh/modern-go/concurrent)
7 | [](https://goreportcard.com/report/github.com/modern-go/concurrent)
8 | [](https://raw.githubusercontent.com/modern-go/concurrent/master/LICENSE)
9 |
10 | * concurrent.Map: backport sync.Map for go below 1.9
11 | * concurrent.Executor: goroutine with explicit ownership and cancellable
12 |
13 | # concurrent.Map
14 |
15 | because sync.Map is only available in go 1.9, we can use concurrent.Map to make code portable
16 |
17 | ```go
18 | m := concurrent.NewMap()
19 | m.Store("hello", "world")
20 | elem, found := m.Load("hello")
21 | // elem will be "world"
22 | // found will be true
23 | ```
24 |
25 | # concurrent.Executor
26 |
27 | ```go
28 | executor := concurrent.NewUnboundedExecutor()
29 | executor.Go(func(ctx context.Context) {
30 | everyMillisecond := time.NewTicker(time.Millisecond)
31 | for {
32 | select {
33 | case <-ctx.Done():
34 | fmt.Println("goroutine exited")
35 | return
36 | case <-everyMillisecond.C:
37 | // do something
38 | }
39 | }
40 | })
41 | time.Sleep(time.Second)
42 | executor.StopAndWaitForever()
43 | fmt.Println("executor stopped")
44 | ```
45 |
46 | attach goroutine to executor instance, so that we can
47 |
48 | * cancel it by stop the executor with Stop/StopAndWait/StopAndWaitForever
49 | * handle panic by callback: the default behavior will no longer crash your application
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/safe_type.go:
--------------------------------------------------------------------------------
1 | package reflect2
2 |
3 | import (
4 | "reflect"
5 | "unsafe"
6 | )
7 |
8 | type safeType struct {
9 | reflect.Type
10 | cfg *frozenConfig
11 | }
12 |
13 | func (type2 *safeType) New() interface{} {
14 | return reflect.New(type2.Type).Interface()
15 | }
16 |
17 | func (type2 *safeType) UnsafeNew() unsafe.Pointer {
18 | panic("does not support unsafe operation")
19 | }
20 |
21 | func (type2 *safeType) Elem() Type {
22 | return type2.cfg.Type2(type2.Type.Elem())
23 | }
24 |
25 | func (type2 *safeType) Type1() reflect.Type {
26 | return type2.Type
27 | }
28 |
29 | func (type2 *safeType) PackEFace(ptr unsafe.Pointer) interface{} {
30 | panic("does not support unsafe operation")
31 | }
32 |
33 | func (type2 *safeType) Implements(thatType Type) bool {
34 | return type2.Type.Implements(thatType.Type1())
35 | }
36 |
37 | func (type2 *safeType) RType() uintptr {
38 | panic("does not support unsafe operation")
39 | }
40 |
41 | func (type2 *safeType) Indirect(obj interface{}) interface{} {
42 | return reflect.Indirect(reflect.ValueOf(obj)).Interface()
43 | }
44 |
45 | func (type2 *safeType) UnsafeIndirect(ptr unsafe.Pointer) interface{} {
46 | panic("does not support unsafe operation")
47 | }
48 |
49 | func (type2 *safeType) LikePtr() bool {
50 | panic("does not support unsafe operation")
51 | }
52 |
53 | func (type2 *safeType) IsNullable() bool {
54 | return IsNullable(type2.Kind())
55 | }
56 |
57 | func (type2 *safeType) IsNil(obj interface{}) bool {
58 | if obj == nil {
59 | return true
60 | }
61 | return reflect.ValueOf(obj).Elem().IsNil()
62 | }
63 |
64 | func (type2 *safeType) UnsafeIsNil(ptr unsafe.Pointer) bool {
65 | panic("does not support unsafe operation")
66 | }
67 |
68 | func (type2 *safeType) Set(obj interface{}, val interface{}) {
69 | reflect.ValueOf(obj).Elem().Set(reflect.ValueOf(val).Elem())
70 | }
71 |
72 | func (type2 *safeType) UnsafeSet(ptr unsafe.Pointer, val unsafe.Pointer) {
73 | panic("does not support unsafe operation")
74 | }
75 |
76 | func (type2 *safeType) AssignableTo(anotherType Type) bool {
77 | return type2.Type1().AssignableTo(anotherType.Type1())
78 | }
79 |
--------------------------------------------------------------------------------
/vendor/github.com/dustin/go-broadcast/broadcaster.go:
--------------------------------------------------------------------------------
1 | /*
2 | Package broadcast provides pubsub of messages over channels.
3 |
4 | A provider has a Broadcaster into which it Submits messages and into
5 | which subscribers Register to pick up those messages.
6 |
7 | */
8 | package broadcast
9 |
10 | type broadcaster struct {
11 | input chan interface{}
12 | reg chan chan<- interface{}
13 | unreg chan chan<- interface{}
14 |
15 | outputs map[chan<- interface{}]bool
16 | }
17 |
18 | // The Broadcaster interface describes the main entry points to
19 | // broadcasters.
20 | type Broadcaster interface {
21 | // Register a new channel to receive broadcasts
22 | Register(chan<- interface{})
23 | // Unregister a channel so that it no longer receives broadcasts.
24 | Unregister(chan<- interface{})
25 | // Shut this broadcaster down.
26 | Close() error
27 | // Submit a new object to all subscribers
28 | Submit(interface{})
29 | }
30 |
31 | func (b *broadcaster) broadcast(m interface{}) {
32 | for ch := range b.outputs {
33 | ch <- m
34 | }
35 | }
36 |
37 | func (b *broadcaster) run() {
38 | for {
39 | select {
40 | case m := <-b.input:
41 | b.broadcast(m)
42 | case ch, ok := <-b.reg:
43 | if ok {
44 | b.outputs[ch] = true
45 | } else {
46 | return
47 | }
48 | case ch := <-b.unreg:
49 | delete(b.outputs, ch)
50 | }
51 | }
52 | }
53 |
54 | // NewBroadcaster creates a new broadcaster with the given input
55 | // channel buffer length.
56 | func NewBroadcaster(buflen int) Broadcaster {
57 | b := &broadcaster{
58 | input: make(chan interface{}, buflen),
59 | reg: make(chan chan<- interface{}),
60 | unreg: make(chan chan<- interface{}),
61 | outputs: make(map[chan<- interface{}]bool),
62 | }
63 |
64 | go b.run()
65 |
66 | return b
67 | }
68 |
69 | func (b *broadcaster) Register(newch chan<- interface{}) {
70 | b.reg <- newch
71 | }
72 |
73 | func (b *broadcaster) Unregister(newch chan<- interface{}) {
74 | b.unreg <- newch
75 | }
76 |
77 | func (b *broadcaster) Close() error {
78 | close(b.reg)
79 | return nil
80 | }
81 |
82 | func (b *broadcaster) Submit(m interface{}) {
83 | if b != nil {
84 | b.input <- m
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/Makefile:
--------------------------------------------------------------------------------
1 | GO ?= go
2 | GOFMT ?= gofmt "-s"
3 | PACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/)
4 | VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/ | grep -v /examples/)
5 | GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")
6 | TESTFOLDER := $(shell $(GO) list ./... | grep -E 'gin$$|binding$$|render$$' | grep -v examples)
7 |
8 | all: install
9 |
10 | install: deps
11 | govendor sync
12 |
13 | .PHONY: test
14 | test:
15 | echo "mode: count" > coverage.out
16 | for d in $(TESTFOLDER); do \
17 | $(GO) test -v -covermode=count -coverprofile=profile.out $$d; \
18 | if [ -f profile.out ]; then \
19 | cat profile.out | grep -v "mode:" >> coverage.out; \
20 | rm profile.out; \
21 | fi; \
22 | done
23 |
24 | .PHONY: fmt
25 | fmt:
26 | $(GOFMT) -w $(GOFILES)
27 |
28 | .PHONY: fmt-check
29 | fmt-check:
30 | @diff=$$($(GOFMT) -d $(GOFILES)); \
31 | if [ -n "$$diff" ]; then \
32 | echo "Please run 'make fmt' and commit the result:"; \
33 | echo "$${diff}"; \
34 | exit 1; \
35 | fi;
36 |
37 | vet:
38 | $(GO) vet $(VETPACKAGES)
39 |
40 | deps:
41 | @hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
42 | $(GO) get -u github.com/kardianos/govendor; \
43 | fi
44 | @hash embedmd > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
45 | $(GO) get -u github.com/campoy/embedmd; \
46 | fi
47 |
48 | embedmd:
49 | embedmd -d *.md
50 |
51 | .PHONY: lint
52 | lint:
53 | @hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
54 | $(GO) get -u golang.org/x/lint/golint; \
55 | fi
56 | for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
57 |
58 | .PHONY: misspell-check
59 | misspell-check:
60 | @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
61 | $(GO) get -u github.com/client9/misspell/cmd/misspell; \
62 | fi
63 | misspell -error $(GOFILES)
64 |
65 | .PHONY: misspell
66 | misspell:
67 | @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
68 | $(GO) get -u github.com/client9/misspell/cmd/misspell; \
69 | fi
70 | misspell -w $(GOFILES)
71 |
72 | .PHONY: tools
73 | tools:
74 | go install golang.org/x/lint/golint; \
75 | go install github.com/client9/misspell/cmd/misspell; \
76 | go install github.com/campoy/embedmd;
77 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-contrib/pprof/README.md:
--------------------------------------------------------------------------------
1 | # pprof
2 |
3 | [](https://travis-ci.org/gin-contrib/pprof)
4 | [](https://codecov.io/gh/gin-contrib/pprof)
5 | [](https://goreportcard.com/report/github.com/gin-contrib/pprof)
6 | [](https://godoc.org/github.com/gin-contrib/pprof)
7 | [](https://gitter.im/gin-gonic/gin)
8 |
9 | gin pprof middleware
10 |
11 | > Package pprof serves via its HTTP server runtime profiling data in the format expected by the pprof visualization tool.
12 |
13 | ## Usage
14 |
15 | ### Start using it
16 |
17 | Download and install it:
18 |
19 | ```bash
20 | $ go get github.com/gin-contrib/pprof
21 | ```
22 |
23 | Import it in your code:
24 |
25 | ```go
26 | import "github.com/gin-contrib/pprof"
27 | ```
28 |
29 | ### Example:
30 |
31 | ```go
32 | package main
33 |
34 | import (
35 | "github.com/gin-contrib/pprof"
36 | "github.com/gin-gonic/gin"
37 | )
38 |
39 | func main() {
40 | router := gin.Default()
41 | pprof.Register(router)
42 | router.Run(":8080")
43 | }
44 | ```
45 |
46 | ### change default path prefix:
47 |
48 | ```go
49 | func main() {
50 | router := gin.Default()
51 | // default is "debug/pprof"
52 | pprof.Register(router, "dev/pprof")
53 | router.Run(":8080")
54 | }
55 | ```
56 |
57 | ### Use the pprof tool
58 |
59 | Then use the pprof tool to look at the heap profile:
60 |
61 | ```bash
62 | go tool pprof http://localhost:8080/debug/pprof/heap
63 | ```
64 |
65 | Or to look at a 30-second CPU profile:
66 |
67 | ```bash
68 | go tool pprof http://localhost:8080/debug/pprof/profile
69 | ```
70 |
71 | Or to look at the goroutine blocking profile, after calling runtime.SetBlockProfileRate in your program:
72 |
73 | ```bash
74 | go tool pprof http://localhost:8080/debug/pprof/block
75 | ```
76 |
77 | Or to collect a 5-second execution trace:
78 |
79 | ```bash
80 | wget http://localhost:8080/debug/pprof/trace?seconds=5
81 | ```
82 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/iter_skip_strict.go:
--------------------------------------------------------------------------------
1 | //+build !jsoniter_sloppy
2 |
3 | package jsoniter
4 |
5 | import "fmt"
6 |
7 | func (iter *Iterator) skipNumber() {
8 | if !iter.trySkipNumber() {
9 | iter.unreadByte()
10 | iter.ReadFloat32()
11 | }
12 | }
13 |
14 | func (iter *Iterator) trySkipNumber() bool {
15 | dotFound := false
16 | for i := iter.head; i < iter.tail; i++ {
17 | c := iter.buf[i]
18 | switch c {
19 | case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
20 | case '.':
21 | if dotFound {
22 | iter.ReportError("validateNumber", `more than one dot found in number`)
23 | return true // already failed
24 | }
25 | if i+1 == iter.tail {
26 | return false
27 | }
28 | c = iter.buf[i+1]
29 | switch c {
30 | case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
31 | default:
32 | iter.ReportError("validateNumber", `missing digit after dot`)
33 | return true // already failed
34 | }
35 | dotFound = true
36 | default:
37 | switch c {
38 | case ',', ']', '}', ' ', '\t', '\n', '\r':
39 | if iter.head == i {
40 | return false // if - without following digits
41 | }
42 | iter.head = i
43 | return true // must be valid
44 | }
45 | return false // may be invalid
46 | }
47 | }
48 | return false
49 | }
50 |
51 | func (iter *Iterator) skipString() {
52 | if !iter.trySkipString() {
53 | iter.unreadByte()
54 | iter.ReadString()
55 | }
56 | }
57 |
58 | func (iter *Iterator) trySkipString() bool {
59 | for i := iter.head; i < iter.tail; i++ {
60 | c := iter.buf[i]
61 | if c == '"' {
62 | iter.head = i + 1
63 | return true // valid
64 | } else if c == '\\' {
65 | return false
66 | } else if c < ' ' {
67 | iter.ReportError("trySkipString",
68 | fmt.Sprintf(`invalid control character found: %d`, c))
69 | return true // already failed
70 | }
71 | }
72 | return false
73 | }
74 |
75 | func (iter *Iterator) skipObject() {
76 | iter.unreadByte()
77 | iter.ReadObjectCB(func(iter *Iterator, field string) bool {
78 | iter.Skip()
79 | return true
80 | })
81 | }
82 |
83 | func (iter *Iterator) skipArray() {
84 | iter.unreadByte()
85 | iter.ReadArrayCB(func(iter *Iterator) bool {
86 | iter.Skip()
87 | return true
88 | })
89 | }
90 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/mode.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package gin
6 |
7 | import (
8 | "io"
9 | "os"
10 |
11 | "github.com/gin-gonic/gin/binding"
12 | )
13 |
14 | // ENV_GIN_MODE indicates environment name for gin mode.
15 | const ENV_GIN_MODE = "GIN_MODE"
16 |
17 | const (
18 | // DebugMode indicates gin mode is debug.
19 | DebugMode = "debug"
20 | // ReleaseMode indicates gin mode is relase.
21 | ReleaseMode = "release"
22 | // TestMode indicates gin mode is test.
23 | TestMode = "test"
24 | )
25 | const (
26 | debugCode = iota
27 | releaseCode
28 | testCode
29 | )
30 |
31 | // DefaultWriter is the default io.Writer used the Gin for debug output and
32 | // middleware output like Logger() or Recovery().
33 | // Note that both Logger and Recovery provides custom ways to configure their
34 | // output io.Writer.
35 | // To support coloring in Windows use:
36 | // import "github.com/mattn/go-colorable"
37 | // gin.DefaultWriter = colorable.NewColorableStdout()
38 | var DefaultWriter io.Writer = os.Stdout
39 | var DefaultErrorWriter io.Writer = os.Stderr
40 |
41 | var ginMode = debugCode
42 | var modeName = DebugMode
43 |
44 | func init() {
45 | mode := os.Getenv(ENV_GIN_MODE)
46 | SetMode(mode)
47 | }
48 |
49 | // SetMode sets gin mode according to input string.
50 | func SetMode(value string) {
51 | switch value {
52 | case DebugMode, "":
53 | ginMode = debugCode
54 | case ReleaseMode:
55 | ginMode = releaseCode
56 | case TestMode:
57 | ginMode = testCode
58 | default:
59 | panic("gin mode unknown: " + value)
60 | }
61 | if value == "" {
62 | value = DebugMode
63 | }
64 | modeName = value
65 | }
66 |
67 | // DisableBindValidation closes the default validator.
68 | func DisableBindValidation() {
69 | binding.Validator = nil
70 | }
71 |
72 | // EnableJsonDecoderUseNumber sets true for binding.EnableDecoderUseNumberto to
73 | // call the UseNumber method on the JSON Decoder instance.
74 | func EnableJsonDecoderUseNumber() {
75 | binding.EnableDecoderUseNumber = true
76 | }
77 |
78 | // Mode returns currently gin mode.
79 | func Mode() string {
80 | return modeName
81 | }
82 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/unsafe_array.go:
--------------------------------------------------------------------------------
1 | package reflect2
2 |
3 | import (
4 | "reflect"
5 | "unsafe"
6 | )
7 |
8 | type UnsafeArrayType struct {
9 | unsafeType
10 | elemRType unsafe.Pointer
11 | pElemRType unsafe.Pointer
12 | elemSize uintptr
13 | likePtr bool
14 | }
15 |
16 | func newUnsafeArrayType(cfg *frozenConfig, type1 reflect.Type) *UnsafeArrayType {
17 | return &UnsafeArrayType{
18 | unsafeType: *newUnsafeType(cfg, type1),
19 | elemRType: unpackEFace(type1.Elem()).data,
20 | pElemRType: unpackEFace(reflect.PtrTo(type1.Elem())).data,
21 | elemSize: type1.Elem().Size(),
22 | likePtr: likePtrType(type1),
23 | }
24 | }
25 |
26 | func (type2 *UnsafeArrayType) LikePtr() bool {
27 | return type2.likePtr
28 | }
29 |
30 | func (type2 *UnsafeArrayType) Indirect(obj interface{}) interface{} {
31 | objEFace := unpackEFace(obj)
32 | assertType("Type.Indirect argument 1", type2.ptrRType, objEFace.rtype)
33 | return type2.UnsafeIndirect(objEFace.data)
34 | }
35 |
36 | func (type2 *UnsafeArrayType) UnsafeIndirect(ptr unsafe.Pointer) interface{} {
37 | if type2.likePtr {
38 | return packEFace(type2.rtype, *(*unsafe.Pointer)(ptr))
39 | }
40 | return packEFace(type2.rtype, ptr)
41 | }
42 |
43 | func (type2 *UnsafeArrayType) SetIndex(obj interface{}, index int, elem interface{}) {
44 | objEFace := unpackEFace(obj)
45 | assertType("ArrayType.SetIndex argument 1", type2.ptrRType, objEFace.rtype)
46 | elemEFace := unpackEFace(elem)
47 | assertType("ArrayType.SetIndex argument 3", type2.pElemRType, elemEFace.rtype)
48 | type2.UnsafeSetIndex(objEFace.data, index, elemEFace.data)
49 | }
50 |
51 | func (type2 *UnsafeArrayType) UnsafeSetIndex(obj unsafe.Pointer, index int, elem unsafe.Pointer) {
52 | elemPtr := arrayAt(obj, index, type2.elemSize, "i < s.Len")
53 | typedmemmove(type2.elemRType, elemPtr, elem)
54 | }
55 |
56 | func (type2 *UnsafeArrayType) GetIndex(obj interface{}, index int) interface{} {
57 | objEFace := unpackEFace(obj)
58 | assertType("ArrayType.GetIndex argument 1", type2.ptrRType, objEFace.rtype)
59 | elemPtr := type2.UnsafeGetIndex(objEFace.data, index)
60 | return packEFace(type2.pElemRType, elemPtr)
61 | }
62 |
63 | func (type2 *UnsafeArrayType) UnsafeGetIndex(obj unsafe.Pointer, index int) unsafe.Pointer {
64 | return arrayAt(obj, index, type2.elemSize, "i < s.Len")
65 | }
66 |
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl:
--------------------------------------------------------------------------------
1 | {{var "v"}} := *{{ .Varname }}
2 | {{var "l"}} := r.ReadMapStart()
3 | {{var "bh"}} := z.DecBasicHandle()
4 | if {{var "v"}} == nil {
5 | {{var "rl"}} := z.DecInferLen({{var "l"}}, {{var "bh"}}.MaxInitLen, {{ .Size }})
6 | {{var "v"}} = make(map[{{ .KTyp }}]{{ .Typ }}, {{var "rl"}})
7 | *{{ .Varname }} = {{var "v"}}
8 | }
9 | var {{var "mk"}} {{ .KTyp }}
10 | var {{var "mv"}} {{ .Typ }}
11 | var {{var "mg"}}, {{var "mdn"}} {{if decElemKindPtr}}, {{var "ms"}}, {{var "mok"}}{{end}} bool
12 | if {{var "bh"}}.MapValueReset {
13 | {{if decElemKindPtr}}{{var "mg"}} = true
14 | {{else if decElemKindIntf}}if !{{var "bh"}}.InterfaceReset { {{var "mg"}} = true }
15 | {{else if not decElemKindImmutable}}{{var "mg"}} = true
16 | {{end}} }
17 | if {{var "l"}} != 0 {
18 | {{var "hl"}} := {{var "l"}} > 0
19 | for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || r.CheckBreak()); {{var "j"}}++ {
20 | r.ReadMapElemKey() {{/* z.DecSendContainerState(codecSelfer_containerMapKey{{ .Sfx }}) */}}
21 | {{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x }}
22 | {{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */}}if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} {
23 | {{var "mk"}} = string({{var "bv"}})
24 | }{{ end }}{{if decElemKindPtr}}
25 | {{var "ms"}} = true{{end}}
26 | if {{var "mg"}} {
27 | {{if decElemKindPtr}}{{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}]
28 | if {{var "mok"}} {
29 | {{var "ms"}} = false
30 | } {{else}}{{var "mv"}} = {{var "v"}}[{{var "mk"}}] {{end}}
31 | } {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}}
32 | r.ReadMapElemValue() {{/* z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }}) */}}
33 | {{var "mdn"}} = false
34 | {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ $y := printf "%vmdn%v" .TempVar .Rand }}{{ decLineVar $x $y }}
35 | if {{var "mdn"}} {
36 | if {{ var "bh" }}.DeleteOnNilMapValue { delete({{var "v"}}, {{var "mk"}}) } else { {{var "v"}}[{{var "mk"}}] = {{decElemZero}} }
37 | } else if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil {
38 | {{var "v"}}[{{var "mk"}}] = {{var "mv"}}
39 | }
40 | }
41 | } // else len==0: TODO: Should we clear map entries?
42 | r.ReadMapEnd() {{/* z.DecSendContainerState(codecSelfer_containerMapEnd{{ .Sfx }}) */}}
43 |
--------------------------------------------------------------------------------
/vendor/github.com/client9/misspell/legal.go:
--------------------------------------------------------------------------------
1 | // Package misspell corrects commonly misspelled English words in source files.
2 | package misspell
3 |
4 | // Legal provides licensing info.
5 | const Legal = `
6 | Execept where noted below, the source code for misspell is
7 | copyright Nick Galbreath and distribution is allowed under a
8 | MIT license. See the following for details:
9 |
10 | * https://github.com/client9/misspell/blob/master/LICENSE
11 | * https://tldrlegal.com/license/mit-license
12 |
13 | Misspell makes uses of the Golang standard library and
14 | contains a modified version of Golang's strings.Replacer
15 | which are covered under a BSD License.
16 |
17 | * https://golang.org/pkg/strings/#Replacer
18 | * https://golang.org/src/strings/replace.go
19 | * https://github.com/golang/go/blob/master/LICENSE
20 |
21 | Copyright (c) 2009 The Go Authors. All rights reserved.
22 |
23 | Redistribution and use in source and binary forms, with or without
24 | modification, are permitted provided that the following conditions are
25 | met:
26 |
27 | * Redistributions of source code must retain the above copyright
28 | notice, this list of conditions and the following disclaimer.
29 | * Redistributions in binary form must reproduce the above
30 | copyright notice, this list of conditions and the following disclaimer
31 | in the documentation and/or other materials provided with the
32 | distribution.
33 | * Neither the name of Google Inc. nor the names of its
34 | contributors may be used to endorse or promote products derived from
35 | this software without specific prior written permission.
36 |
37 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
38 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
39 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
40 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
41 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
45 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
47 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 | `
49 |
--------------------------------------------------------------------------------
/vendor/github.com/client9/misspell/notwords.go:
--------------------------------------------------------------------------------
1 | package misspell
2 |
3 | import (
4 | "bytes"
5 | "regexp"
6 | "strings"
7 | )
8 |
9 | var (
10 | reEmail = regexp.MustCompile(`[a-zA-Z0-9_.%+-]+@[a-zA-Z0-9-.]+\.[a-zA-Z]{2,6}[^a-zA-Z]`)
11 | reHost = regexp.MustCompile(`[a-zA-Z0-9-.]+\.[a-zA-Z]+`)
12 | reBackslash = regexp.MustCompile(`\\[a-z]`)
13 | )
14 |
15 | // RemovePath attempts to strip away embedded file system paths, e.g.
16 | // /foo/bar or /static/myimg.png
17 | //
18 | // TODO: windows style
19 | //
20 | func RemovePath(s string) string {
21 | out := bytes.Buffer{}
22 | var idx int
23 | for len(s) > 0 {
24 | if idx = strings.IndexByte(s, '/'); idx == -1 {
25 | out.WriteString(s)
26 | break
27 | }
28 |
29 | if idx > 0 {
30 | idx--
31 | }
32 |
33 | var chclass string
34 | switch s[idx] {
35 | case '/', ' ', '\n', '\t', '\r':
36 | chclass = " \n\r\t"
37 | case '[':
38 | chclass = "]\n"
39 | case '(':
40 | chclass = ")\n"
41 | default:
42 | out.WriteString(s[:idx+2])
43 | s = s[idx+2:]
44 | continue
45 | }
46 |
47 | endx := strings.IndexAny(s[idx+1:], chclass)
48 | if endx != -1 {
49 | out.WriteString(s[:idx+1])
50 | out.Write(bytes.Repeat([]byte{' '}, endx))
51 | s = s[idx+endx+1:]
52 | } else {
53 | out.WriteString(s)
54 | break
55 | }
56 | }
57 | return out.String()
58 | }
59 |
60 | // replaceWithBlanks returns a string with the same number of spaces as the input
61 | func replaceWithBlanks(s string) string {
62 | return strings.Repeat(" ", len(s))
63 | }
64 |
65 | // RemoveEmail remove email-like strings, e.g. "nickg+junk@xfoobar.com", "nickg@xyz.abc123.biz"
66 | func RemoveEmail(s string) string {
67 | return reEmail.ReplaceAllStringFunc(s, replaceWithBlanks)
68 | }
69 |
70 | // RemoveHost removes host-like strings "foobar.com" "abc123.fo1231.biz"
71 | func RemoveHost(s string) string {
72 | return reHost.ReplaceAllStringFunc(s, replaceWithBlanks)
73 | }
74 |
75 | // RemoveBackslashEscapes removes characters that are preceeded by a backslash
76 | // commonly found in printf format stringd "\nto"
77 | func removeBackslashEscapes(s string) string {
78 | return reBackslash.ReplaceAllStringFunc(s, replaceWithBlanks)
79 | }
80 |
81 | // RemoveNotWords blanks out all the not words
82 | func RemoveNotWords(s string) string {
83 | // do most selective/specific first
84 | return removeBackslashEscapes(RemoveHost(RemoveEmail(RemovePath(StripURL(s)))))
85 | }
86 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/unsafe_field.go:
--------------------------------------------------------------------------------
1 | package reflect2
2 |
3 | import (
4 | "reflect"
5 | "unsafe"
6 | )
7 |
8 | type UnsafeStructField struct {
9 | reflect.StructField
10 | structType *UnsafeStructType
11 | rtype unsafe.Pointer
12 | ptrRType unsafe.Pointer
13 | }
14 |
15 | func newUnsafeStructField(structType *UnsafeStructType, structField reflect.StructField) *UnsafeStructField {
16 | return &UnsafeStructField{
17 | StructField: structField,
18 | rtype: unpackEFace(structField.Type).data,
19 | ptrRType: unpackEFace(reflect.PtrTo(structField.Type)).data,
20 | structType: structType,
21 | }
22 | }
23 |
24 | func (field *UnsafeStructField) Offset() uintptr {
25 | return field.StructField.Offset
26 | }
27 |
28 | func (field *UnsafeStructField) Name() string {
29 | return field.StructField.Name
30 | }
31 |
32 | func (field *UnsafeStructField) PkgPath() string {
33 | return field.StructField.PkgPath
34 | }
35 |
36 | func (field *UnsafeStructField) Type() Type {
37 | return field.structType.cfg.Type2(field.StructField.Type)
38 | }
39 |
40 | func (field *UnsafeStructField) Tag() reflect.StructTag {
41 | return field.StructField.Tag
42 | }
43 |
44 | func (field *UnsafeStructField) Index() []int {
45 | return field.StructField.Index
46 | }
47 |
48 | func (field *UnsafeStructField) Anonymous() bool {
49 | return field.StructField.Anonymous
50 | }
51 |
52 | func (field *UnsafeStructField) Set(obj interface{}, value interface{}) {
53 | objEFace := unpackEFace(obj)
54 | assertType("StructField.SetIndex argument 1", field.structType.ptrRType, objEFace.rtype)
55 | valueEFace := unpackEFace(value)
56 | assertType("StructField.SetIndex argument 2", field.ptrRType, valueEFace.rtype)
57 | field.UnsafeSet(objEFace.data, valueEFace.data)
58 | }
59 |
60 | func (field *UnsafeStructField) UnsafeSet(obj unsafe.Pointer, value unsafe.Pointer) {
61 | fieldPtr := add(obj, field.StructField.Offset, "same as non-reflect &v.field")
62 | typedmemmove(field.rtype, fieldPtr, value)
63 | }
64 |
65 | func (field *UnsafeStructField) Get(obj interface{}) interface{} {
66 | objEFace := unpackEFace(obj)
67 | assertType("StructField.GetIndex argument 1", field.structType.ptrRType, objEFace.rtype)
68 | value := field.UnsafeGet(objEFace.data)
69 | return packEFace(field.ptrRType, value)
70 | }
71 |
72 | func (field *UnsafeStructField) UnsafeGet(obj unsafe.Pointer) unsafe.Pointer {
73 | return add(obj, field.StructField.Offset, "same as non-reflect &v.field")
74 | }
75 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-isatty/isatty_windows.go:
--------------------------------------------------------------------------------
1 | // +build windows
2 | // +build !appengine
3 |
4 | package isatty
5 |
6 | import (
7 | "strings"
8 | "syscall"
9 | "unicode/utf16"
10 | "unsafe"
11 | )
12 |
13 | const (
14 | fileNameInfo uintptr = 2
15 | fileTypePipe = 3
16 | )
17 |
18 | var (
19 | kernel32 = syscall.NewLazyDLL("kernel32.dll")
20 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
21 | procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx")
22 | procGetFileType = kernel32.NewProc("GetFileType")
23 | )
24 |
25 | func init() {
26 | // Check if GetFileInformationByHandleEx is available.
27 | if procGetFileInformationByHandleEx.Find() != nil {
28 | procGetFileInformationByHandleEx = nil
29 | }
30 | }
31 |
32 | // IsTerminal return true if the file descriptor is terminal.
33 | func IsTerminal(fd uintptr) bool {
34 | var st uint32
35 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0)
36 | return r != 0 && e == 0
37 | }
38 |
39 | // Check pipe name is used for cygwin/msys2 pty.
40 | // Cygwin/MSYS2 PTY has a name like:
41 | // \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master
42 | func isCygwinPipeName(name string) bool {
43 | token := strings.Split(name, "-")
44 | if len(token) < 5 {
45 | return false
46 | }
47 |
48 | if token[0] != `\msys` && token[0] != `\cygwin` {
49 | return false
50 | }
51 |
52 | if token[1] == "" {
53 | return false
54 | }
55 |
56 | if !strings.HasPrefix(token[2], "pty") {
57 | return false
58 | }
59 |
60 | if token[3] != `from` && token[3] != `to` {
61 | return false
62 | }
63 |
64 | if token[4] != "master" {
65 | return false
66 | }
67 |
68 | return true
69 | }
70 |
71 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
72 | // terminal.
73 | func IsCygwinTerminal(fd uintptr) bool {
74 | if procGetFileInformationByHandleEx == nil {
75 | return false
76 | }
77 |
78 | // Cygwin/msys's pty is a pipe.
79 | ft, _, e := syscall.Syscall(procGetFileType.Addr(), 1, fd, 0, 0)
80 | if ft != fileTypePipe || e != 0 {
81 | return false
82 | }
83 |
84 | var buf [2 + syscall.MAX_PATH]uint16
85 | r, _, e := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(),
86 | 4, fd, fileNameInfo, uintptr(unsafe.Pointer(&buf)),
87 | uintptr(len(buf)*2), 0, 0)
88 | if r == 0 || e != 0 {
89 | return false
90 | }
91 |
92 | l := *(*uint32)(unsafe.Pointer(&buf))
93 | return isCygwinPipeName(string(utf16.Decode(buf[2 : 2+l/2])))
94 | }
95 |
--------------------------------------------------------------------------------
/vendor/github.com/client9/misspell/Makefile:
--------------------------------------------------------------------------------
1 | CONTAINER=nickg/misspell
2 |
3 | install: ## install misspell into GOPATH/bin
4 | go install ./cmd/misspell
5 |
6 | build: hooks ## build and lint misspell
7 | ./scripts/build.sh
8 |
9 | test: ## run all tests
10 | go test .
11 |
12 | # real publishing is done only by travis
13 | publish: ## test goreleaser
14 | ./scripts/goreleaser-dryrun.sh
15 |
16 | # the grep in line 2 is to remove misspellings in the spelling dictionary
17 | # that trigger false positives!!
18 | falsepositives: /scowl-wl
19 | cat /scowl-wl/words-US-60.txt | \
20 | grep -i -v -E "payed|Tyre|Euclidian|nonoccurence|dependancy|reenforced|accidently|surprize|dependance|idealogy|binominal|causalities|conquerer|withing|casette|analyse|analogue|dialogue|paralyse|catalogue|archaeolog|clarinettist|catalyses|cancell|chisell|ageing|cataloguing" | \
21 | misspell -debug -error
22 | cat /scowl-wl/words-GB-ise-60.txt | \
23 | grep -v -E "payed|nonoccurence|withing" | \
24 | misspell -locale=UK -debug -error
25 | # cat /scowl-wl/words-GB-ize-60.txt | \
26 | # grep -v -E "withing" | \
27 | # misspell -debug -error
28 | # cat /scowl-wl/words-CA-60.txt | \
29 | # grep -v -E "withing" | \
30 | # misspell -debug -error
31 |
32 | bench: ## run benchmarks
33 | go test -bench '.*'
34 |
35 | clean: ## clean up time
36 | rm -rf dist/ bin/
37 | go clean ./...
38 | git gc --aggressive
39 |
40 | ci: ## run test like travis-ci does, requires docker
41 | docker run --rm \
42 | -v $(PWD):/go/src/github.com/client9/misspell \
43 | -w /go/src/github.com/client9/misspell \
44 | ${CONTAINER} \
45 | make build falsepositives
46 |
47 | docker-build: ## build a docker test image
48 | docker build -t ${CONTAINER} .
49 |
50 | docker-pull: ## pull latest test image
51 | docker pull ${CONTAINER}
52 |
53 | docker-console: ## log into the test image
54 | docker run --rm -it \
55 | -v $(PWD):/go/src/github.com/client9/misspell \
56 | -w /go/src/github.com/client9/misspell \
57 | ${CONTAINER} sh
58 |
59 | .git/hooks/pre-commit: scripts/pre-commit.sh
60 | cp -f scripts/pre-commit.sh .git/hooks/pre-commit
61 | .git/hooks/commit-msg: scripts/commit-msg.sh
62 | cp -f scripts/commit-msg.sh .git/hooks/commit-msg
63 | hooks: .git/hooks/pre-commit .git/hooks/commit-msg ## install git precommit hooks
64 |
65 | .PHONY: help ci console docker-build bench
66 |
67 | # https://www.client9.com/self-documenting-makefiles/
68 | help:
69 | @awk -F ':|##' '/^[^\t].+?:.*?##/ {\
70 | printf "\033[36m%-30s\033[0m %s\n", $$1, $$NF \
71 | }' $(MAKEFILE_LIST)
72 | .DEFAULT_GOAL=help
73 | .PHONY=help
74 |
75 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/unsafe_type.go:
--------------------------------------------------------------------------------
1 | package reflect2
2 |
3 | import (
4 | "reflect"
5 | "unsafe"
6 | )
7 |
8 | type unsafeType struct {
9 | safeType
10 | rtype unsafe.Pointer
11 | ptrRType unsafe.Pointer
12 | }
13 |
14 | func newUnsafeType(cfg *frozenConfig, type1 reflect.Type) *unsafeType {
15 | return &unsafeType{
16 | safeType: safeType{
17 | Type: type1,
18 | cfg: cfg,
19 | },
20 | rtype: unpackEFace(type1).data,
21 | ptrRType: unpackEFace(reflect.PtrTo(type1)).data,
22 | }
23 | }
24 |
25 | func (type2 *unsafeType) Set(obj interface{}, val interface{}) {
26 | objEFace := unpackEFace(obj)
27 | assertType("Type.Set argument 1", type2.ptrRType, objEFace.rtype)
28 | valEFace := unpackEFace(val)
29 | assertType("Type.Set argument 2", type2.ptrRType, valEFace.rtype)
30 | type2.UnsafeSet(objEFace.data, valEFace.data)
31 | }
32 |
33 | func (type2 *unsafeType) UnsafeSet(ptr unsafe.Pointer, val unsafe.Pointer) {
34 | typedmemmove(type2.rtype, ptr, val)
35 | }
36 |
37 | func (type2 *unsafeType) IsNil(obj interface{}) bool {
38 | objEFace := unpackEFace(obj)
39 | assertType("Type.IsNil argument 1", type2.ptrRType, objEFace.rtype)
40 | return type2.UnsafeIsNil(objEFace.data)
41 | }
42 |
43 | func (type2 *unsafeType) UnsafeIsNil(ptr unsafe.Pointer) bool {
44 | return ptr == nil
45 | }
46 |
47 | func (type2 *unsafeType) UnsafeNew() unsafe.Pointer {
48 | return unsafe_New(type2.rtype)
49 | }
50 |
51 | func (type2 *unsafeType) New() interface{} {
52 | return packEFace(type2.ptrRType, type2.UnsafeNew())
53 | }
54 |
55 | func (type2 *unsafeType) PackEFace(ptr unsafe.Pointer) interface{} {
56 | return packEFace(type2.ptrRType, ptr)
57 | }
58 |
59 | func (type2 *unsafeType) RType() uintptr {
60 | return uintptr(type2.rtype)
61 | }
62 |
63 | func (type2 *unsafeType) Indirect(obj interface{}) interface{} {
64 | objEFace := unpackEFace(obj)
65 | assertType("Type.Indirect argument 1", type2.ptrRType, objEFace.rtype)
66 | return type2.UnsafeIndirect(objEFace.data)
67 | }
68 |
69 | func (type2 *unsafeType) UnsafeIndirect(obj unsafe.Pointer) interface{} {
70 | return packEFace(type2.rtype, obj)
71 | }
72 |
73 | func (type2 *unsafeType) LikePtr() bool {
74 | return false
75 | }
76 |
77 | func assertType(where string, expectRType unsafe.Pointer, actualRType unsafe.Pointer) {
78 | if expectRType != actualRType {
79 | expectType := reflect.TypeOf(0)
80 | (*iface)(unsafe.Pointer(&expectType)).data = expectRType
81 | actualType := reflect.TypeOf(0)
82 | (*iface)(unsafe.Pointer(&actualType)).data = actualRType
83 | panic(where + ": expect " + expectType.String() + ", actual " + actualType.String())
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/any_bool.go:
--------------------------------------------------------------------------------
1 | package jsoniter
2 |
3 | type trueAny struct {
4 | baseAny
5 | }
6 |
7 | func (any *trueAny) LastError() error {
8 | return nil
9 | }
10 |
11 | func (any *trueAny) ToBool() bool {
12 | return true
13 | }
14 |
15 | func (any *trueAny) ToInt() int {
16 | return 1
17 | }
18 |
19 | func (any *trueAny) ToInt32() int32 {
20 | return 1
21 | }
22 |
23 | func (any *trueAny) ToInt64() int64 {
24 | return 1
25 | }
26 |
27 | func (any *trueAny) ToUint() uint {
28 | return 1
29 | }
30 |
31 | func (any *trueAny) ToUint32() uint32 {
32 | return 1
33 | }
34 |
35 | func (any *trueAny) ToUint64() uint64 {
36 | return 1
37 | }
38 |
39 | func (any *trueAny) ToFloat32() float32 {
40 | return 1
41 | }
42 |
43 | func (any *trueAny) ToFloat64() float64 {
44 | return 1
45 | }
46 |
47 | func (any *trueAny) ToString() string {
48 | return "true"
49 | }
50 |
51 | func (any *trueAny) WriteTo(stream *Stream) {
52 | stream.WriteTrue()
53 | }
54 |
55 | func (any *trueAny) Parse() *Iterator {
56 | return nil
57 | }
58 |
59 | func (any *trueAny) GetInterface() interface{} {
60 | return true
61 | }
62 |
63 | func (any *trueAny) ValueType() ValueType {
64 | return BoolValue
65 | }
66 |
67 | func (any *trueAny) MustBeValid() Any {
68 | return any
69 | }
70 |
71 | type falseAny struct {
72 | baseAny
73 | }
74 |
75 | func (any *falseAny) LastError() error {
76 | return nil
77 | }
78 |
79 | func (any *falseAny) ToBool() bool {
80 | return false
81 | }
82 |
83 | func (any *falseAny) ToInt() int {
84 | return 0
85 | }
86 |
87 | func (any *falseAny) ToInt32() int32 {
88 | return 0
89 | }
90 |
91 | func (any *falseAny) ToInt64() int64 {
92 | return 0
93 | }
94 |
95 | func (any *falseAny) ToUint() uint {
96 | return 0
97 | }
98 |
99 | func (any *falseAny) ToUint32() uint32 {
100 | return 0
101 | }
102 |
103 | func (any *falseAny) ToUint64() uint64 {
104 | return 0
105 | }
106 |
107 | func (any *falseAny) ToFloat32() float32 {
108 | return 0
109 | }
110 |
111 | func (any *falseAny) ToFloat64() float64 {
112 | return 0
113 | }
114 |
115 | func (any *falseAny) ToString() string {
116 | return "false"
117 | }
118 |
119 | func (any *falseAny) WriteTo(stream *Stream) {
120 | stream.WriteFalse()
121 | }
122 |
123 | func (any *falseAny) Parse() *Iterator {
124 | return nil
125 | }
126 |
127 | func (any *falseAny) GetInterface() interface{} {
128 | return false
129 | }
130 |
131 | func (any *falseAny) ValueType() ValueType {
132 | return BoolValue
133 | }
134 |
135 | func (any *falseAny) MustBeValid() Any {
136 | return any
137 | }
138 |
--------------------------------------------------------------------------------
/vendor/github.com/json-iterator/go/stream_float.go:
--------------------------------------------------------------------------------
1 | package jsoniter
2 |
3 | import (
4 | "math"
5 | "strconv"
6 | )
7 |
8 | var pow10 []uint64
9 |
10 | func init() {
11 | pow10 = []uint64{1, 10, 100, 1000, 10000, 100000, 1000000}
12 | }
13 |
14 | // WriteFloat32 write float32 to stream
15 | func (stream *Stream) WriteFloat32(val float32) {
16 | abs := math.Abs(float64(val))
17 | fmt := byte('f')
18 | // Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right.
19 | if abs != 0 {
20 | if float32(abs) < 1e-6 || float32(abs) >= 1e21 {
21 | fmt = 'e'
22 | }
23 | }
24 | stream.buf = strconv.AppendFloat(stream.buf, float64(val), fmt, -1, 32)
25 | }
26 |
27 | // WriteFloat32Lossy write float32 to stream with ONLY 6 digits precision although much much faster
28 | func (stream *Stream) WriteFloat32Lossy(val float32) {
29 | if val < 0 {
30 | stream.writeByte('-')
31 | val = -val
32 | }
33 | if val > 0x4ffffff {
34 | stream.WriteFloat32(val)
35 | return
36 | }
37 | precision := 6
38 | exp := uint64(1000000) // 6
39 | lval := uint64(float64(val)*float64(exp) + 0.5)
40 | stream.WriteUint64(lval / exp)
41 | fval := lval % exp
42 | if fval == 0 {
43 | return
44 | }
45 | stream.writeByte('.')
46 | for p := precision - 1; p > 0 && fval < pow10[p]; p-- {
47 | stream.writeByte('0')
48 | }
49 | stream.WriteUint64(fval)
50 | for stream.buf[len(stream.buf)-1] == '0' {
51 | stream.buf = stream.buf[:len(stream.buf)-1]
52 | }
53 | }
54 |
55 | // WriteFloat64 write float64 to stream
56 | func (stream *Stream) WriteFloat64(val float64) {
57 | abs := math.Abs(val)
58 | fmt := byte('f')
59 | // Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right.
60 | if abs != 0 {
61 | if abs < 1e-6 || abs >= 1e21 {
62 | fmt = 'e'
63 | }
64 | }
65 | stream.buf = strconv.AppendFloat(stream.buf, float64(val), fmt, -1, 64)
66 | }
67 |
68 | // WriteFloat64Lossy write float64 to stream with ONLY 6 digits precision although much much faster
69 | func (stream *Stream) WriteFloat64Lossy(val float64) {
70 | if val < 0 {
71 | stream.writeByte('-')
72 | val = -val
73 | }
74 | if val > 0x4ffffff {
75 | stream.WriteFloat64(val)
76 | return
77 | }
78 | precision := 6
79 | exp := uint64(1000000) // 6
80 | lval := uint64(val*float64(exp) + 0.5)
81 | stream.WriteUint64(lval / exp)
82 | fval := lval % exp
83 | if fval == 0 {
84 | return
85 | }
86 | stream.writeByte('.')
87 | for p := precision - 1; p > 0 && fval < pow10[p]; p-- {
88 | stream.writeByte('0')
89 | }
90 | stream.WriteUint64(fval)
91 | for stream.buf[len(stream.buf)-1] == '0' {
92 | stream.buf = stream.buf[:len(stream.buf)-1]
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/README.md:
--------------------------------------------------------------------------------
1 | # reflect2
2 |
3 | [](https://sourcegraph.com/github.com/modern-go/reflect2?badge)
4 | [](http://godoc.org/github.com/modern-go/reflect2)
5 | [](https://travis-ci.org/modern-go/reflect2)
6 | [](https://codecov.io/gh/modern-go/reflect2)
7 | [](https://goreportcard.com/report/github.com/modern-go/reflect2)
8 | [](https://raw.githubusercontent.com/modern-go/reflect2/master/LICENSE)
9 |
10 | reflect api that avoids runtime reflect.Value cost
11 |
12 | * reflect get/set interface{}, with type checking
13 | * reflect get/set unsafe.Pointer, without type checking
14 | * `reflect2.TypeByName` works like `Class.forName` found in java
15 |
16 | [json-iterator](https://github.com/json-iterator/go) use this package to save runtime dispatching cost.
17 | This package is designed for low level libraries to optimize reflection performance.
18 | General application should still use reflect standard library.
19 |
20 | # reflect2.TypeByName
21 |
22 | ```go
23 | // given package is github.com/your/awesome-package
24 | type MyStruct struct {
25 | // ...
26 | }
27 |
28 | // will return the type
29 | reflect2.TypeByName("awesome-package.MyStruct")
30 | // however, if the type has not been used
31 | // it will be eliminated by compiler, so we can not get it in runtime
32 | ```
33 |
34 | # reflect2 get/set interface{}
35 |
36 | ```go
37 | valType := reflect2.TypeOf(1)
38 | i := 1
39 | j := 10
40 | valType.Set(&i, &j)
41 | // i will be 10
42 | ```
43 |
44 | to get set `type`, always use its pointer `*type`
45 |
46 | # reflect2 get/set unsafe.Pointer
47 |
48 | ```go
49 | valType := reflect2.TypeOf(1)
50 | i := 1
51 | j := 10
52 | valType.UnsafeSet(unsafe.Pointer(&i), unsafe.Pointer(&j))
53 | // i will be 10
54 | ```
55 |
56 | to get set `type`, always use its pointer `*type`
57 |
58 | # benchmark
59 |
60 | Benchmark is not necessary for this package. It does nothing actually.
61 | As it is just a thin wrapper to make go runtime public.
62 | Both `reflect2` and `reflect` call same function
63 | provided by `runtime` package exposed by go language.
64 |
65 | # unsafe safety
66 |
67 | Instead of casting `[]byte` to `sliceHeader` in your application using unsafe.
68 | We can use reflect2 instead. This way, if `sliceHeader` changes in the future,
69 | only reflect2 need to be upgraded.
70 |
71 | reflect2 tries its best to keep the implementation same as reflect (by testing).
--------------------------------------------------------------------------------
/vendor/github.com/gin-contrib/sse/sse-encoder.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package sse
6 |
7 | import (
8 | "encoding/json"
9 | "fmt"
10 | "io"
11 | "net/http"
12 | "reflect"
13 | "strconv"
14 | "strings"
15 | )
16 |
17 | // Server-Sent Events
18 | // W3C Working Draft 29 October 2009
19 | // http://www.w3.org/TR/2009/WD-eventsource-20091029/
20 |
21 | const ContentType = "text/event-stream"
22 |
23 | var contentType = []string{ContentType}
24 | var noCache = []string{"no-cache"}
25 |
26 | var fieldReplacer = strings.NewReplacer(
27 | "\n", "\\n",
28 | "\r", "\\r")
29 |
30 | var dataReplacer = strings.NewReplacer(
31 | "\n", "\ndata:",
32 | "\r", "\\r")
33 |
34 | type Event struct {
35 | Event string
36 | Id string
37 | Retry uint
38 | Data interface{}
39 | }
40 |
41 | func Encode(writer io.Writer, event Event) error {
42 | w := checkWriter(writer)
43 | writeId(w, event.Id)
44 | writeEvent(w, event.Event)
45 | writeRetry(w, event.Retry)
46 | return writeData(w, event.Data)
47 | }
48 |
49 | func writeId(w stringWriter, id string) {
50 | if len(id) > 0 {
51 | w.WriteString("id:")
52 | fieldReplacer.WriteString(w, id)
53 | w.WriteString("\n")
54 | }
55 | }
56 |
57 | func writeEvent(w stringWriter, event string) {
58 | if len(event) > 0 {
59 | w.WriteString("event:")
60 | fieldReplacer.WriteString(w, event)
61 | w.WriteString("\n")
62 | }
63 | }
64 |
65 | func writeRetry(w stringWriter, retry uint) {
66 | if retry > 0 {
67 | w.WriteString("retry:")
68 | w.WriteString(strconv.FormatUint(uint64(retry), 10))
69 | w.WriteString("\n")
70 | }
71 | }
72 |
73 | func writeData(w stringWriter, data interface{}) error {
74 | w.WriteString("data:")
75 | switch kindOfData(data) {
76 | case reflect.Struct, reflect.Slice, reflect.Map:
77 | err := json.NewEncoder(w).Encode(data)
78 | if err != nil {
79 | return err
80 | }
81 | w.WriteString("\n")
82 | default:
83 | dataReplacer.WriteString(w, fmt.Sprint(data))
84 | w.WriteString("\n\n")
85 | }
86 | return nil
87 | }
88 |
89 | func (r Event) Render(w http.ResponseWriter) error {
90 | r.WriteContentType(w)
91 | return Encode(w, r)
92 | }
93 |
94 | func (r Event) WriteContentType(w http.ResponseWriter) {
95 | header := w.Header()
96 | header["Content-Type"] = contentType
97 |
98 | if _, exist := header["Cache-Control"]; !exist {
99 | header["Cache-Control"] = noCache
100 | }
101 | }
102 |
103 | func kindOfData(data interface{}) reflect.Kind {
104 | value := reflect.ValueOf(data)
105 | valueType := value.Kind()
106 | if valueType == reflect.Ptr {
107 | valueType = value.Elem().Kind()
108 | }
109 | return valueType
110 | }
111 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/safe_slice.go:
--------------------------------------------------------------------------------
1 | package reflect2
2 |
3 | import (
4 | "reflect"
5 | "unsafe"
6 | )
7 |
8 | type safeSliceType struct {
9 | safeType
10 | }
11 |
12 | func (type2 *safeSliceType) SetIndex(obj interface{}, index int, value interface{}) {
13 | val := reflect.ValueOf(obj).Elem()
14 | elem := reflect.ValueOf(value).Elem()
15 | val.Index(index).Set(elem)
16 | }
17 |
18 | func (type2 *safeSliceType) UnsafeSetIndex(obj unsafe.Pointer, index int, value unsafe.Pointer) {
19 | panic("does not support unsafe operation")
20 | }
21 |
22 | func (type2 *safeSliceType) GetIndex(obj interface{}, index int) interface{} {
23 | val := reflect.ValueOf(obj).Elem()
24 | elem := val.Index(index)
25 | ptr := reflect.New(elem.Type())
26 | ptr.Elem().Set(elem)
27 | return ptr.Interface()
28 | }
29 |
30 | func (type2 *safeSliceType) UnsafeGetIndex(obj unsafe.Pointer, index int) unsafe.Pointer {
31 | panic("does not support unsafe operation")
32 | }
33 |
34 | func (type2 *safeSliceType) MakeSlice(length int, cap int) interface{} {
35 | val := reflect.MakeSlice(type2.Type, length, cap)
36 | ptr := reflect.New(val.Type())
37 | ptr.Elem().Set(val)
38 | return ptr.Interface()
39 | }
40 |
41 | func (type2 *safeSliceType) UnsafeMakeSlice(length int, cap int) unsafe.Pointer {
42 | panic("does not support unsafe operation")
43 | }
44 |
45 | func (type2 *safeSliceType) Grow(obj interface{}, newLength int) {
46 | oldCap := type2.Cap(obj)
47 | oldSlice := reflect.ValueOf(obj).Elem()
48 | delta := newLength - oldCap
49 | deltaVals := make([]reflect.Value, delta)
50 | newSlice := reflect.Append(oldSlice, deltaVals...)
51 | oldSlice.Set(newSlice)
52 | }
53 |
54 | func (type2 *safeSliceType) UnsafeGrow(ptr unsafe.Pointer, newLength int) {
55 | panic("does not support unsafe operation")
56 | }
57 |
58 | func (type2 *safeSliceType) Append(obj interface{}, elem interface{}) {
59 | val := reflect.ValueOf(obj).Elem()
60 | elemVal := reflect.ValueOf(elem).Elem()
61 | newVal := reflect.Append(val, elemVal)
62 | val.Set(newVal)
63 | }
64 |
65 | func (type2 *safeSliceType) UnsafeAppend(obj unsafe.Pointer, elem unsafe.Pointer) {
66 | panic("does not support unsafe operation")
67 | }
68 |
69 | func (type2 *safeSliceType) SetNil(obj interface{}) {
70 | val := reflect.ValueOf(obj).Elem()
71 | val.Set(reflect.Zero(val.Type()))
72 | }
73 |
74 | func (type2 *safeSliceType) UnsafeSetNil(ptr unsafe.Pointer) {
75 | panic("does not support unsafe operation")
76 | }
77 |
78 | func (type2 *safeSliceType) LengthOf(obj interface{}) int {
79 | return reflect.ValueOf(obj).Elem().Len()
80 | }
81 |
82 | func (type2 *safeSliceType) UnsafeLengthOf(ptr unsafe.Pointer) int {
83 | panic("does not support unsafe operation")
84 | }
85 |
86 | func (type2 *safeSliceType) Cap(obj interface{}) int {
87 | return reflect.ValueOf(obj).Elem().Cap()
88 | }
89 |
90 | func (type2 *safeSliceType) UnsafeCap(ptr unsafe.Pointer) int {
91 | panic("does not support unsafe operation")
92 | }
93 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/render/html.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package render
6 |
7 | import (
8 | "html/template"
9 | "net/http"
10 | )
11 |
12 | // Delims represents a set of Left and Right delimiters for HTML template rendering.
13 | type Delims struct {
14 | // Left delimiter, defaults to {{.
15 | Left string
16 | // Right delimiter, defaults to }}.
17 | Right string
18 | }
19 |
20 | // HTMLRender interface is to be implemented by HTMLProduction and HTMLDebug.
21 | type HTMLRender interface {
22 | // Instance returns an HTML instance.
23 | Instance(string, interface{}) Render
24 | }
25 |
26 | // HTMLProduction contains template reference and its delims.
27 | type HTMLProduction struct {
28 | Template *template.Template
29 | Delims Delims
30 | }
31 |
32 | // HTMLDebug contains template delims and pattern and function with file list.
33 | type HTMLDebug struct {
34 | Files []string
35 | Glob string
36 | Delims Delims
37 | FuncMap template.FuncMap
38 | }
39 |
40 | // HTML contains template reference and its name with given interface object.
41 | type HTML struct {
42 | Template *template.Template
43 | Name string
44 | Data interface{}
45 | }
46 |
47 | var htmlContentType = []string{"text/html; charset=utf-8"}
48 |
49 | // Instance (HTMLProduction) returns an HTML instance which it realizes Render interface.
50 | func (r HTMLProduction) Instance(name string, data interface{}) Render {
51 | return HTML{
52 | Template: r.Template,
53 | Name: name,
54 | Data: data,
55 | }
56 | }
57 |
58 | // Instance (HTMLDebug) returns an HTML instance which it realizes Render interface.
59 | func (r HTMLDebug) Instance(name string, data interface{}) Render {
60 | return HTML{
61 | Template: r.loadTemplate(),
62 | Name: name,
63 | Data: data,
64 | }
65 | }
66 | func (r HTMLDebug) loadTemplate() *template.Template {
67 | if r.FuncMap == nil {
68 | r.FuncMap = template.FuncMap{}
69 | }
70 | if len(r.Files) > 0 {
71 | return template.Must(template.New("").Delims(r.Delims.Left, r.Delims.Right).Funcs(r.FuncMap).ParseFiles(r.Files...))
72 | }
73 | if r.Glob != "" {
74 | return template.Must(template.New("").Delims(r.Delims.Left, r.Delims.Right).Funcs(r.FuncMap).ParseGlob(r.Glob))
75 | }
76 | panic("the HTML debug render was created without files or glob pattern")
77 | }
78 |
79 | // Render (HTML) executes template and writes its result with custom ContentType for response.
80 | func (r HTML) Render(w http.ResponseWriter) error {
81 | r.WriteContentType(w)
82 |
83 | if r.Name == "" {
84 | return r.Template.Execute(w, r.Data)
85 | }
86 | return r.Template.ExecuteTemplate(w, r.Name, r.Data)
87 | }
88 |
89 | // WriteContentType (HTML) writes HTML ContentType.
90 | func (r HTML) WriteContentType(w http.ResponseWriter) {
91 | writeContentType(w, htmlContentType)
92 | }
93 |
--------------------------------------------------------------------------------
/vendor/github.com/campoy/embedmd/embedmd/command.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 Google Inc. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | // http://www.apache.org/licenses/LICENSE-2.0
6 | //
7 | // Unless required by applicable law or agreed to writing, software distributed
8 | // under the License is distributed on a "AS IS" BASIS, WITHOUT WARRANTIES OR
9 | // CONDITIONS OF ANY KIND, either express or implied.
10 | //
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 |
14 | package embedmd
15 |
16 | import (
17 | "errors"
18 | "path/filepath"
19 | "strings"
20 | )
21 |
22 | type command struct {
23 | path, lang string
24 | start, end *string
25 | }
26 |
27 | func parseCommand(s string) (*command, error) {
28 | s = strings.TrimSpace(s)
29 | if len(s) < 2 || s[0] != '(' || s[len(s)-1] != ')' {
30 | return nil, errors.New("argument list should be in parenthesis")
31 | }
32 |
33 | args, err := fields(s[1 : len(s)-1])
34 | if err != nil {
35 | return nil, err
36 | }
37 | if len(args) == 0 {
38 | return nil, errors.New("missing file name")
39 | }
40 |
41 | cmd := &command{path: args[0]}
42 | args = args[1:]
43 | if len(args) > 0 && args[0][0] != '/' {
44 | cmd.lang, args = args[0], args[1:]
45 | } else {
46 | ext := filepath.Ext(cmd.path[1:])
47 | if len(ext) == 0 {
48 | return nil, errors.New("language is required when file has no extension")
49 | }
50 | cmd.lang = ext[1:]
51 | }
52 |
53 | switch {
54 | case len(args) == 1:
55 | cmd.start = &args[0]
56 | case len(args) == 2:
57 | cmd.start, cmd.end = &args[0], &args[1]
58 | case len(args) > 2:
59 | return nil, errors.New("too many arguments")
60 | }
61 |
62 | return cmd, nil
63 | }
64 |
65 | // fields returns a list of the groups of text separated by blanks,
66 | // keeping all text surrounded by / as a group.
67 | func fields(s string) ([]string, error) {
68 | var args []string
69 |
70 | for s = strings.TrimSpace(s); len(s) > 0; s = strings.TrimSpace(s) {
71 | if s[0] == '/' {
72 | sep := nextSlash(s[1:])
73 | if sep < 0 {
74 | return nil, errors.New("unbalanced /")
75 | }
76 | args, s = append(args, s[:sep+2]), s[sep+2:]
77 | } else {
78 | sep := strings.IndexByte(s[1:], ' ')
79 | if sep < 0 {
80 | return append(args, s), nil
81 | }
82 | args, s = append(args, s[:sep+1]), s[sep+1:]
83 | }
84 | }
85 |
86 | return args, nil
87 | }
88 |
89 | // nextSlash will find the index of the next unescaped slash in a string.
90 | func nextSlash(s string) int {
91 | for sep := 0; ; sep++ {
92 | i := strings.IndexByte(s[sep:], '/')
93 | if i < 0 {
94 | return -1
95 | }
96 | sep += i
97 | if sep == 0 || s[sep-1] != '\\' {
98 | return sep
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/unsafe_link.go:
--------------------------------------------------------------------------------
1 | package reflect2
2 |
3 | import "unsafe"
4 |
5 | //go:linkname unsafe_New reflect.unsafe_New
6 | func unsafe_New(rtype unsafe.Pointer) unsafe.Pointer
7 |
8 | //go:linkname typedmemmove reflect.typedmemmove
9 | func typedmemmove(rtype unsafe.Pointer, dst, src unsafe.Pointer)
10 |
11 | //go:linkname unsafe_NewArray reflect.unsafe_NewArray
12 | func unsafe_NewArray(rtype unsafe.Pointer, length int) unsafe.Pointer
13 |
14 | // typedslicecopy copies a slice of elemType values from src to dst,
15 | // returning the number of elements copied.
16 | //go:linkname typedslicecopy reflect.typedslicecopy
17 | //go:noescape
18 | func typedslicecopy(elemType unsafe.Pointer, dst, src sliceHeader) int
19 |
20 | //go:linkname mapassign reflect.mapassign
21 | //go:noescape
22 | func mapassign(rtype unsafe.Pointer, m unsafe.Pointer, key, val unsafe.Pointer)
23 |
24 | //go:linkname mapaccess reflect.mapaccess
25 | //go:noescape
26 | func mapaccess(rtype unsafe.Pointer, m unsafe.Pointer, key unsafe.Pointer) (val unsafe.Pointer)
27 |
28 | // m escapes into the return value, but the caller of mapiterinit
29 | // doesn't let the return value escape.
30 | //go:noescape
31 | //go:linkname mapiterinit reflect.mapiterinit
32 | func mapiterinit(rtype unsafe.Pointer, m unsafe.Pointer) *hiter
33 |
34 | //go:noescape
35 | //go:linkname mapiternext reflect.mapiternext
36 | func mapiternext(it *hiter)
37 |
38 | //go:linkname ifaceE2I reflect.ifaceE2I
39 | func ifaceE2I(rtype unsafe.Pointer, src interface{}, dst unsafe.Pointer)
40 |
41 | // A hash iteration structure.
42 | // If you modify hiter, also change cmd/internal/gc/reflect.go to indicate
43 | // the layout of this structure.
44 | type hiter struct {
45 | key unsafe.Pointer // Must be in first position. Write nil to indicate iteration end (see cmd/internal/gc/range.go).
46 | value unsafe.Pointer // Must be in second position (see cmd/internal/gc/range.go).
47 | // rest fields are ignored
48 | }
49 |
50 | // add returns p+x.
51 | //
52 | // The whySafe string is ignored, so that the function still inlines
53 | // as efficiently as p+x, but all call sites should use the string to
54 | // record why the addition is safe, which is to say why the addition
55 | // does not cause x to advance to the very end of p's allocation
56 | // and therefore point incorrectly at the next block in memory.
57 | func add(p unsafe.Pointer, x uintptr, whySafe string) unsafe.Pointer {
58 | return unsafe.Pointer(uintptr(p) + x)
59 | }
60 |
61 | // arrayAt returns the i-th element of p,
62 | // an array whose elements are eltSize bytes wide.
63 | // The array pointed at by p must have at least i+1 elements:
64 | // it is invalid (but impossible to check here) to pass i >= len,
65 | // because then the result will point outside the array.
66 | // whySafe must explain why i < len. (Passing "i < len" is fine;
67 | // the benefit is to surface this assumption at the call site.)
68 | func arrayAt(p unsafe.Pointer, i int, eltSize uintptr, whySafe string) unsafe.Pointer {
69 | return add(p, uintptr(i)*eltSize, "i < len")
70 | }
71 |
--------------------------------------------------------------------------------
/vendor/github.com/gin-gonic/gin/response_writer.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2 | // Use of this source code is governed by a MIT style
3 | // license that can be found in the LICENSE file.
4 |
5 | package gin
6 |
7 | import (
8 | "bufio"
9 | "io"
10 | "net"
11 | "net/http"
12 | )
13 |
14 | const (
15 | noWritten = -1
16 | defaultStatus = http.StatusOK
17 | )
18 |
19 | type responseWriterBase interface {
20 | http.ResponseWriter
21 | http.Hijacker
22 | http.Flusher
23 | http.CloseNotifier
24 |
25 | // Returns the HTTP response status code of the current request.
26 | Status() int
27 |
28 | // Returns the number of bytes already written into the response http body.
29 | // See Written()
30 | Size() int
31 |
32 | // Writes the string into the response body.
33 | WriteString(string) (int, error)
34 |
35 | // Returns true if the response body was already written.
36 | Written() bool
37 |
38 | // Forces to write the http header (status code + headers).
39 | WriteHeaderNow()
40 | }
41 |
42 | type responseWriter struct {
43 | http.ResponseWriter
44 | size int
45 | status int
46 | }
47 |
48 | var _ ResponseWriter = &responseWriter{}
49 |
50 | func (w *responseWriter) reset(writer http.ResponseWriter) {
51 | w.ResponseWriter = writer
52 | w.size = noWritten
53 | w.status = defaultStatus
54 | }
55 |
56 | func (w *responseWriter) WriteHeader(code int) {
57 | if code > 0 && w.status != code {
58 | if w.Written() {
59 | debugPrint("[WARNING] Headers were already written. Wanted to override status code %d with %d", w.status, code)
60 | }
61 | w.status = code
62 | }
63 | }
64 |
65 | func (w *responseWriter) WriteHeaderNow() {
66 | if !w.Written() {
67 | w.size = 0
68 | w.ResponseWriter.WriteHeader(w.status)
69 | }
70 | }
71 |
72 | func (w *responseWriter) Write(data []byte) (n int, err error) {
73 | w.WriteHeaderNow()
74 | n, err = w.ResponseWriter.Write(data)
75 | w.size += n
76 | return
77 | }
78 |
79 | func (w *responseWriter) WriteString(s string) (n int, err error) {
80 | w.WriteHeaderNow()
81 | n, err = io.WriteString(w.ResponseWriter, s)
82 | w.size += n
83 | return
84 | }
85 |
86 | func (w *responseWriter) Status() int {
87 | return w.status
88 | }
89 |
90 | func (w *responseWriter) Size() int {
91 | return w.size
92 | }
93 |
94 | func (w *responseWriter) Written() bool {
95 | return w.size != noWritten
96 | }
97 |
98 | // Hijack implements the http.Hijacker interface.
99 | func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
100 | if w.size < 0 {
101 | w.size = 0
102 | }
103 | return w.ResponseWriter.(http.Hijacker).Hijack()
104 | }
105 |
106 | // CloseNotify implements the http.CloseNotify interface.
107 | func (w *responseWriter) CloseNotify() <-chan bool {
108 | return w.ResponseWriter.(http.CloseNotifier).CloseNotify()
109 | }
110 |
111 | // Flush implements the http.Flush interface.
112 | func (w *responseWriter) Flush() {
113 | w.WriteHeaderNow()
114 | w.ResponseWriter.(http.Flusher).Flush()
115 | }
116 |
--------------------------------------------------------------------------------
/vendor/github.com/modern-go/reflect2/safe_map.go:
--------------------------------------------------------------------------------
1 | package reflect2
2 |
3 | import (
4 | "reflect"
5 | "unsafe"
6 | )
7 |
8 | type safeMapType struct {
9 | safeType
10 | }
11 |
12 | func (type2 *safeMapType) Key() Type {
13 | return type2.safeType.cfg.Type2(type2.Type.Key())
14 | }
15 |
16 | func (type2 *safeMapType) MakeMap(cap int) interface{} {
17 | ptr := reflect.New(type2.Type)
18 | ptr.Elem().Set(reflect.MakeMap(type2.Type))
19 | return ptr.Interface()
20 | }
21 |
22 | func (type2 *safeMapType) UnsafeMakeMap(cap int) unsafe.Pointer {
23 | panic("does not support unsafe operation")
24 | }
25 |
26 | func (type2 *safeMapType) SetIndex(obj interface{}, key interface{}, elem interface{}) {
27 | keyVal := reflect.ValueOf(key)
28 | elemVal := reflect.ValueOf(elem)
29 | val := reflect.ValueOf(obj)
30 | val.Elem().SetMapIndex(keyVal.Elem(), elemVal.Elem())
31 | }
32 |
33 | func (type2 *safeMapType) UnsafeSetIndex(obj unsafe.Pointer, key unsafe.Pointer, elem unsafe.Pointer) {
34 | panic("does not support unsafe operation")
35 | }
36 |
37 | func (type2 *safeMapType) TryGetIndex(obj interface{}, key interface{}) (interface{}, bool) {
38 | keyVal := reflect.ValueOf(key)
39 | if key == nil {
40 | keyVal = reflect.New(type2.Type.Key()).Elem()
41 | }
42 | val := reflect.ValueOf(obj).MapIndex(keyVal)
43 | if !val.IsValid() {
44 | return nil, false
45 | }
46 | return val.Interface(), true
47 | }
48 |
49 | func (type2 *safeMapType) GetIndex(obj interface{}, key interface{}) interface{} {
50 | val := reflect.ValueOf(obj).Elem()
51 | keyVal := reflect.ValueOf(key).Elem()
52 | elemVal := val.MapIndex(keyVal)
53 | if !elemVal.IsValid() {
54 | ptr := reflect.New(reflect.PtrTo(val.Type().Elem()))
55 | return ptr.Elem().Interface()
56 | }
57 | ptr := reflect.New(elemVal.Type())
58 | ptr.Elem().Set(elemVal)
59 | return ptr.Interface()
60 | }
61 |
62 | func (type2 *safeMapType) UnsafeGetIndex(obj unsafe.Pointer, key unsafe.Pointer) unsafe.Pointer {
63 | panic("does not support unsafe operation")
64 | }
65 |
66 | func (type2 *safeMapType) Iterate(obj interface{}) MapIterator {
67 | m := reflect.ValueOf(obj).Elem()
68 | return &safeMapIterator{
69 | m: m,
70 | keys: m.MapKeys(),
71 | }
72 | }
73 |
74 | func (type2 *safeMapType) UnsafeIterate(obj unsafe.Pointer) MapIterator {
75 | panic("does not support unsafe operation")
76 | }
77 |
78 | type safeMapIterator struct {
79 | i int
80 | m reflect.Value
81 | keys []reflect.Value
82 | }
83 |
84 | func (iter *safeMapIterator) HasNext() bool {
85 | return iter.i != len(iter.keys)
86 | }
87 |
88 | func (iter *safeMapIterator) Next() (interface{}, interface{}) {
89 | key := iter.keys[iter.i]
90 | elem := iter.m.MapIndex(key)
91 | iter.i += 1
92 | keyPtr := reflect.New(key.Type())
93 | keyPtr.Elem().Set(key)
94 | elemPtr := reflect.New(elem.Type())
95 | elemPtr.Elem().Set(elem)
96 | return keyPtr.Interface(), elemPtr.Interface()
97 | }
98 |
99 | func (iter *safeMapIterator) UnsafeNext() (unsafe.Pointer, unsafe.Pointer) {
100 | panic("does not support unsafe operation")
101 | }
102 |
--------------------------------------------------------------------------------
/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl:
--------------------------------------------------------------------------------
1 | {{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }}
2 | {{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}}{{if not isArray}}
3 | var {{var "c"}} bool {{/* // changed */}}
4 | _ = {{var "c"}}{{end}}
5 | if {{var "l"}} == 0 {
6 | {{if isSlice }}if {{var "v"}} == nil {
7 | {{var "v"}} = []{{ .Typ }}{}
8 | {{var "c"}} = true
9 | } else if len({{var "v"}}) != 0 {
10 | {{var "v"}} = {{var "v"}}[:0]
11 | {{var "c"}} = true
12 | } {{else if isChan }}if {{var "v"}} == nil {
13 | {{var "v"}} = make({{ .CTyp }}, 0)
14 | {{var "c"}} = true
15 | } {{end}}
16 | } else {
17 | {{var "hl"}} := {{var "l"}} > 0
18 | var {{var "rl"}} int
19 | _ = {{var "rl"}}
20 | {{if isSlice }} if {{var "hl"}} {
21 | if {{var "l"}} > cap({{var "v"}}) {
22 | {{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
23 | if {{var "rl"}} <= cap({{var "v"}}) {
24 | {{var "v"}} = {{var "v"}}[:{{var "rl"}}]
25 | } else {
26 | {{var "v"}} = make([]{{ .Typ }}, {{var "rl"}})
27 | }
28 | {{var "c"}} = true
29 | } else if {{var "l"}} != len({{var "v"}}) {
30 | {{var "v"}} = {{var "v"}}[:{{var "l"}}]
31 | {{var "c"}} = true
32 | }
33 | } {{end}}
34 | var {{var "j"}} int
35 | // var {{var "dn"}} bool
36 | for ; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || r.CheckBreak()); {{var "j"}}++ {
37 | {{if not isArray}} if {{var "j"}} == 0 && {{var "v"}} == nil {
38 | if {{var "hl"}} {
39 | {{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
40 | } else {
41 | {{var "rl"}} = {{if isSlice}}8{{else if isChan}}64{{end}}
42 | }
43 | {{var "v"}} = make({{if isSlice}}[]{{ .Typ }}{{else if isChan}}{{.CTyp}}{{end}}, {{var "rl"}})
44 | {{var "c"}} = true
45 | }{{end}}
46 | {{var "h"}}.ElemContainerState({{var "j"}})
47 | {{/* {{var "dn"}} = r.TryDecodeAsNil() */}}{{/* commented out, as decLineVar handles this already each time */}}
48 | {{if isChan}}{{ $x := printf "%[1]vvcx%[2]v" .TempVar .Rand }}var {{$x}} {{ .Typ }}
49 | {{ decLineVar $x }}
50 | {{var "v"}} <- {{ $x }}
51 | // println(">>>> sending ", {{ $x }}, " into ", {{var "v"}}) // TODO: remove this
52 | {{else}}{{/* // if indefinite, etc, then expand the slice if necessary */}}
53 | var {{var "db"}} bool
54 | if {{var "j"}} >= len({{var "v"}}) {
55 | {{if isSlice }} {{var "v"}} = append({{var "v"}}, {{ zero }})
56 | {{var "c"}} = true
57 | {{else}} z.DecArrayCannotExpand(len(v), {{var "j"}}+1); {{var "db"}} = true
58 | {{end}}
59 | }
60 | if {{var "db"}} {
61 | z.DecSwallow()
62 | } else {
63 | {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }}
64 | }
65 | {{end}}
66 | }
67 | {{if isSlice}} if {{var "j"}} < len({{var "v"}}) {
68 | {{var "v"}} = {{var "v"}}[:{{var "j"}}]
69 | {{var "c"}} = true
70 | } else if {{var "j"}} == 0 && {{var "v"}} == nil {
71 | {{var "v"}} = make([]{{ .Typ }}, 0)
72 | {{var "c"}} = true
73 | } {{end}}
74 | }
75 | {{var "h"}}.End()
76 | {{if not isArray }}if {{var "c"}} {
77 | *{{ .Varname }} = {{var "v"}}
78 | }{{end}}
79 |
--------------------------------------------------------------------------------