53 |
54 | Notes:
55 |
56 | 1. Large messages are fragmented in [Chrome's new WebSocket implementation](http://www.ietf.org/mail-archive/web/hybi/current/msg10503.html).
57 | 2. The application can get the type of a received data message by implementing
58 | a [Codec marshal](http://godoc.org/golang.org/x/net/websocket#Codec.Marshal)
59 | function.
60 | 3. The go.net io.Reader and io.Writer operate across WebSocket frame boundaries.
61 | Read returns when the input buffer is full or a frame boundary is
62 | encountered. Each call to Write sends a single frame message. The Gorilla
63 | io.Reader and io.WriteCloser operate on a single WebSocket message.
64 |
65 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/gorilla/websocket/client_clone.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build go1.8
6 |
7 | package websocket
8 |
9 | import "crypto/tls"
10 |
11 | func cloneTLSConfig(cfg *tls.Config) *tls.Config {
12 | if cfg == nil {
13 | return &tls.Config{}
14 | }
15 | return cfg.Clone()
16 | }
17 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/gorilla/websocket/client_clone_legacy.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !go1.8
6 |
7 | package websocket
8 |
9 | import "crypto/tls"
10 |
11 | // cloneTLSConfig clones all public fields except the fields
12 | // SessionTicketsDisabled and SessionTicketKey. This avoids copying the
13 | // sync.Mutex in the sync.Once and makes it safe to call cloneTLSConfig on a
14 | // config in active use.
15 | func cloneTLSConfig(cfg *tls.Config) *tls.Config {
16 | if cfg == nil {
17 | return &tls.Config{}
18 | }
19 | return &tls.Config{
20 | Rand: cfg.Rand,
21 | Time: cfg.Time,
22 | Certificates: cfg.Certificates,
23 | NameToCertificate: cfg.NameToCertificate,
24 | GetCertificate: cfg.GetCertificate,
25 | RootCAs: cfg.RootCAs,
26 | NextProtos: cfg.NextProtos,
27 | ServerName: cfg.ServerName,
28 | ClientAuth: cfg.ClientAuth,
29 | ClientCAs: cfg.ClientCAs,
30 | InsecureSkipVerify: cfg.InsecureSkipVerify,
31 | CipherSuites: cfg.CipherSuites,
32 | PreferServerCipherSuites: cfg.PreferServerCipherSuites,
33 | ClientSessionCache: cfg.ClientSessionCache,
34 | MinVersion: cfg.MinVersion,
35 | MaxVersion: cfg.MaxVersion,
36 | CurvePreferences: cfg.CurvePreferences,
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/gorilla/websocket/compression.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Gorilla WebSocket Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package websocket
6 |
7 | import (
8 | "compress/flate"
9 | "errors"
10 | "io"
11 | "strings"
12 | "sync"
13 | )
14 |
15 | const (
16 | minCompressionLevel = -2 // flate.HuffmanOnly not defined in Go < 1.6
17 | maxCompressionLevel = flate.BestCompression
18 | defaultCompressionLevel = 1
19 | )
20 |
21 | var (
22 | flateWriterPools [maxCompressionLevel - minCompressionLevel + 1]sync.Pool
23 | flateReaderPool = sync.Pool{New: func() interface{} {
24 | return flate.NewReader(nil)
25 | }}
26 | )
27 |
28 | func decompressNoContextTakeover(r io.Reader) io.ReadCloser {
29 | const tail =
30 | // Add four bytes as specified in RFC
31 | "\x00\x00\xff\xff" +
32 | // Add final block to squelch unexpected EOF error from flate reader.
33 | "\x01\x00\x00\xff\xff"
34 |
35 | fr, _ := flateReaderPool.Get().(io.ReadCloser)
36 | fr.(flate.Resetter).Reset(io.MultiReader(r, strings.NewReader(tail)), nil)
37 | return &flateReadWrapper{fr}
38 | }
39 |
40 | func isValidCompressionLevel(level int) bool {
41 | return minCompressionLevel <= level && level <= maxCompressionLevel
42 | }
43 |
44 | func compressNoContextTakeover(w io.WriteCloser, level int) io.WriteCloser {
45 | p := &flateWriterPools[level-minCompressionLevel]
46 | tw := &truncWriter{w: w}
47 | fw, _ := p.Get().(*flate.Writer)
48 | if fw == nil {
49 | fw, _ = flate.NewWriter(tw, level)
50 | } else {
51 | fw.Reset(tw)
52 | }
53 | return &flateWriteWrapper{fw: fw, tw: tw, p: p}
54 | }
55 |
56 | // truncWriter is an io.Writer that writes all but the last four bytes of the
57 | // stream to another io.Writer.
58 | type truncWriter struct {
59 | w io.WriteCloser
60 | n int
61 | p [4]byte
62 | }
63 |
64 | func (w *truncWriter) Write(p []byte) (int, error) {
65 | n := 0
66 |
67 | // fill buffer first for simplicity.
68 | if w.n < len(w.p) {
69 | n = copy(w.p[w.n:], p)
70 | p = p[n:]
71 | w.n += n
72 | if len(p) == 0 {
73 | return n, nil
74 | }
75 | }
76 |
77 | m := len(p)
78 | if m > len(w.p) {
79 | m = len(w.p)
80 | }
81 |
82 | if nn, err := w.w.Write(w.p[:m]); err != nil {
83 | return n + nn, err
84 | }
85 |
86 | copy(w.p[:], w.p[m:])
87 | copy(w.p[len(w.p)-m:], p[len(p)-m:])
88 | nn, err := w.w.Write(p[:len(p)-m])
89 | return n + nn, err
90 | }
91 |
92 | type flateWriteWrapper struct {
93 | fw *flate.Writer
94 | tw *truncWriter
95 | p *sync.Pool
96 | }
97 |
98 | func (w *flateWriteWrapper) Write(p []byte) (int, error) {
99 | if w.fw == nil {
100 | return 0, errWriteClosed
101 | }
102 | return w.fw.Write(p)
103 | }
104 |
105 | func (w *flateWriteWrapper) Close() error {
106 | if w.fw == nil {
107 | return errWriteClosed
108 | }
109 | err1 := w.fw.Flush()
110 | w.p.Put(w.fw)
111 | w.fw = nil
112 | if w.tw.p != [4]byte{0, 0, 0xff, 0xff} {
113 | return errors.New("websocket: internal error, unexpected bytes at end of flate stream")
114 | }
115 | err2 := w.tw.w.Close()
116 | if err1 != nil {
117 | return err1
118 | }
119 | return err2
120 | }
121 |
122 | type flateReadWrapper struct {
123 | fr io.ReadCloser
124 | }
125 |
126 | func (r *flateReadWrapper) Read(p []byte) (int, error) {
127 | if r.fr == nil {
128 | return 0, io.ErrClosedPipe
129 | }
130 | n, err := r.fr.Read(p)
131 | if err == io.EOF {
132 | // Preemptively place the reader back in the pool. This helps with
133 | // scenarios where the application does not call NextReader() soon after
134 | // this final read.
135 | r.Close()
136 | }
137 | return n, err
138 | }
139 |
140 | func (r *flateReadWrapper) Close() error {
141 | if r.fr == nil {
142 | return io.ErrClosedPipe
143 | }
144 | err := r.fr.Close()
145 | flateReaderPool.Put(r.fr)
146 | r.fr = nil
147 | return err
148 | }
149 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/gorilla/websocket/conn_write.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build go1.8
6 |
7 | package websocket
8 |
9 | import "net"
10 |
11 | func (c *Conn) writeBufs(bufs ...[]byte) error {
12 | b := net.Buffers(bufs)
13 | _, err := b.WriteTo(c.conn)
14 | return err
15 | }
16 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/gorilla/websocket/conn_write_legacy.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !go1.8
6 |
7 | package websocket
8 |
9 | func (c *Conn) writeBufs(bufs ...[]byte) error {
10 | for _, buf := range bufs {
11 | if len(buf) > 0 {
12 | if _, err := c.conn.Write(buf); err != nil {
13 | return err
14 | }
15 | }
16 | }
17 | return nil
18 | }
19 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/gorilla/websocket/json.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package websocket
6 |
7 | import (
8 | "encoding/json"
9 | "io"
10 | )
11 |
12 | // WriteJSON writes the JSON encoding of v as a message.
13 | //
14 | // Deprecated: Use c.WriteJSON instead.
15 | func WriteJSON(c *Conn, v interface{}) error {
16 | return c.WriteJSON(v)
17 | }
18 |
19 | // WriteJSON writes the JSON encoding of v as a message.
20 | //
21 | // See the documentation for encoding/json Marshal for details about the
22 | // conversion of Go values to JSON.
23 | func (c *Conn) WriteJSON(v interface{}) error {
24 | w, err := c.NextWriter(TextMessage)
25 | if err != nil {
26 | return err
27 | }
28 | err1 := json.NewEncoder(w).Encode(v)
29 | err2 := w.Close()
30 | if err1 != nil {
31 | return err1
32 | }
33 | return err2
34 | }
35 |
36 | // ReadJSON reads the next JSON-encoded message from the connection and stores
37 | // it in the value pointed to by v.
38 | //
39 | // Deprecated: Use c.ReadJSON instead.
40 | func ReadJSON(c *Conn, v interface{}) error {
41 | return c.ReadJSON(v)
42 | }
43 |
44 | // ReadJSON reads the next JSON-encoded message from the connection and stores
45 | // it in the value pointed to by v.
46 | //
47 | // See the documentation for the encoding/json Unmarshal function for details
48 | // about the conversion of JSON to a Go value.
49 | func (c *Conn) ReadJSON(v interface{}) error {
50 | _, r, err := c.NextReader()
51 | if err != nil {
52 | return err
53 | }
54 | err = json.NewDecoder(r).Decode(v)
55 | if err == io.EOF {
56 | // One value is expected in the message.
57 | err = io.ErrUnexpectedEOF
58 | }
59 | return err
60 | }
61 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/gorilla/websocket/mask.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. Use of
2 | // this source code is governed by a BSD-style license that can be found in the
3 | // LICENSE file.
4 |
5 | // +build !appengine
6 |
7 | package websocket
8 |
9 | import "unsafe"
10 |
11 | const wordSize = int(unsafe.Sizeof(uintptr(0)))
12 |
13 | func maskBytes(key [4]byte, pos int, b []byte) int {
14 | // Mask one byte at a time for small buffers.
15 | if len(b) < 2*wordSize {
16 | for i := range b {
17 | b[i] ^= key[pos&3]
18 | pos++
19 | }
20 | return pos & 3
21 | }
22 |
23 | // Mask one byte at a time to word boundary.
24 | if n := int(uintptr(unsafe.Pointer(&b[0]))) % wordSize; n != 0 {
25 | n = wordSize - n
26 | for i := range b[:n] {
27 | b[i] ^= key[pos&3]
28 | pos++
29 | }
30 | b = b[n:]
31 | }
32 |
33 | // Create aligned word size key.
34 | var k [wordSize]byte
35 | for i := range k {
36 | k[i] = key[(pos+i)&3]
37 | }
38 | kw := *(*uintptr)(unsafe.Pointer(&k))
39 |
40 | // Mask one word at a time.
41 | n := (len(b) / wordSize) * wordSize
42 | for i := 0; i < n; i += wordSize {
43 | *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&b[0])) + uintptr(i))) ^= kw
44 | }
45 |
46 | // Mask one byte at a time for remaining bytes.
47 | b = b[n:]
48 | for i := range b {
49 | b[i] ^= key[pos&3]
50 | pos++
51 | }
52 |
53 | return pos & 3
54 | }
55 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/gorilla/websocket/mask_safe.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. Use of
2 | // this source code is governed by a BSD-style license that can be found in the
3 | // LICENSE file.
4 |
5 | // +build appengine
6 |
7 | package websocket
8 |
9 | func maskBytes(key [4]byte, pos int, b []byte) int {
10 | for i := range b {
11 | b[i] ^= key[pos&3]
12 | pos++
13 | }
14 | return pos & 3
15 | }
16 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/gorilla/websocket/prepared.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Gorilla WebSocket Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package websocket
6 |
7 | import (
8 | "bytes"
9 | "net"
10 | "sync"
11 | "time"
12 | )
13 |
14 | // PreparedMessage caches on the wire representations of a message payload.
15 | // Use PreparedMessage to efficiently send a message payload to multiple
16 | // connections. PreparedMessage is especially useful when compression is used
17 | // because the CPU and memory expensive compression operation can be executed
18 | // once for a given set of compression options.
19 | type PreparedMessage struct {
20 | messageType int
21 | data []byte
22 | mu sync.Mutex
23 | frames map[prepareKey]*preparedFrame
24 | }
25 |
26 | // prepareKey defines a unique set of options to cache prepared frames in PreparedMessage.
27 | type prepareKey struct {
28 | isServer bool
29 | compress bool
30 | compressionLevel int
31 | }
32 |
33 | // preparedFrame contains data in wire representation.
34 | type preparedFrame struct {
35 | once sync.Once
36 | data []byte
37 | }
38 |
39 | // NewPreparedMessage returns an initialized PreparedMessage. You can then send
40 | // it to connection using WritePreparedMessage method. Valid wire
41 | // representation will be calculated lazily only once for a set of current
42 | // connection options.
43 | func NewPreparedMessage(messageType int, data []byte) (*PreparedMessage, error) {
44 | pm := &PreparedMessage{
45 | messageType: messageType,
46 | frames: make(map[prepareKey]*preparedFrame),
47 | data: data,
48 | }
49 |
50 | // Prepare a plain server frame.
51 | _, frameData, err := pm.frame(prepareKey{isServer: true, compress: false})
52 | if err != nil {
53 | return nil, err
54 | }
55 |
56 | // To protect against caller modifying the data argument, remember the data
57 | // copied to the plain server frame.
58 | pm.data = frameData[len(frameData)-len(data):]
59 | return pm, nil
60 | }
61 |
62 | func (pm *PreparedMessage) frame(key prepareKey) (int, []byte, error) {
63 | pm.mu.Lock()
64 | frame, ok := pm.frames[key]
65 | if !ok {
66 | frame = &preparedFrame{}
67 | pm.frames[key] = frame
68 | }
69 | pm.mu.Unlock()
70 |
71 | var err error
72 | frame.once.Do(func() {
73 | // Prepare a frame using a 'fake' connection.
74 | // TODO: Refactor code in conn.go to allow more direct construction of
75 | // the frame.
76 | mu := make(chan bool, 1)
77 | mu <- true
78 | var nc prepareConn
79 | c := &Conn{
80 | conn: &nc,
81 | mu: mu,
82 | isServer: key.isServer,
83 | compressionLevel: key.compressionLevel,
84 | enableWriteCompression: true,
85 | writeBuf: make([]byte, defaultWriteBufferSize+maxFrameHeaderSize),
86 | }
87 | if key.compress {
88 | c.newCompressionWriter = compressNoContextTakeover
89 | }
90 | err = c.WriteMessage(pm.messageType, pm.data)
91 | frame.data = nc.buf.Bytes()
92 | })
93 | return pm.messageType, frame.data, err
94 | }
95 |
96 | type prepareConn struct {
97 | buf bytes.Buffer
98 | net.Conn
99 | }
100 |
101 | func (pc *prepareConn) Write(p []byte) (int, error) { return pc.buf.Write(p) }
102 | func (pc *prepareConn) SetWriteDeadline(t time.Time) error { return nil }
103 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/gorilla/websocket/proxy.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Gorilla WebSocket Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package websocket
6 |
7 | import (
8 | "bufio"
9 | "encoding/base64"
10 | "errors"
11 | "net"
12 | "net/http"
13 | "net/url"
14 | "strings"
15 | )
16 |
17 | type netDialerFunc func(network, addr string) (net.Conn, error)
18 |
19 | func (fn netDialerFunc) Dial(network, addr string) (net.Conn, error) {
20 | return fn(network, addr)
21 | }
22 |
23 | func init() {
24 | proxy_RegisterDialerType("http", func(proxyURL *url.URL, forwardDialer proxy_Dialer) (proxy_Dialer, error) {
25 | return &httpProxyDialer{proxyURL: proxyURL, fowardDial: forwardDialer.Dial}, nil
26 | })
27 | }
28 |
29 | type httpProxyDialer struct {
30 | proxyURL *url.URL
31 | fowardDial func(network, addr string) (net.Conn, error)
32 | }
33 |
34 | func (hpd *httpProxyDialer) Dial(network string, addr string) (net.Conn, error) {
35 | hostPort, _ := hostPortNoPort(hpd.proxyURL)
36 | conn, err := hpd.fowardDial(network, hostPort)
37 | if err != nil {
38 | return nil, err
39 | }
40 |
41 | connectHeader := make(http.Header)
42 | if user := hpd.proxyURL.User; user != nil {
43 | proxyUser := user.Username()
44 | if proxyPassword, passwordSet := user.Password(); passwordSet {
45 | credential := base64.StdEncoding.EncodeToString([]byte(proxyUser + ":" + proxyPassword))
46 | connectHeader.Set("Proxy-Authorization", "Basic "+credential)
47 | }
48 | }
49 |
50 | connectReq := &http.Request{
51 | Method: "CONNECT",
52 | URL: &url.URL{Opaque: addr},
53 | Host: addr,
54 | Header: connectHeader,
55 | }
56 |
57 | if err := connectReq.Write(conn); err != nil {
58 | conn.Close()
59 | return nil, err
60 | }
61 |
62 | // Read response. It's OK to use and discard buffered reader here becaue
63 | // the remote server does not speak until spoken to.
64 | br := bufio.NewReader(conn)
65 | resp, err := http.ReadResponse(br, connectReq)
66 | if err != nil {
67 | conn.Close()
68 | return nil, err
69 | }
70 |
71 | if resp.StatusCode != 200 {
72 | conn.Close()
73 | f := strings.SplitN(resp.Status, " ", 2)
74 | return nil, errors.New(f[1])
75 | }
76 | return conn, nil
77 | }
78 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/gorilla/websocket/trace.go:
--------------------------------------------------------------------------------
1 | // +build go1.8
2 |
3 | package websocket
4 |
5 | import (
6 | "crypto/tls"
7 | "net/http/httptrace"
8 | )
9 |
10 | func doHandshakeWithTrace(trace *httptrace.ClientTrace, tlsConn *tls.Conn, cfg *tls.Config) error {
11 | if trace.TLSHandshakeStart != nil {
12 | trace.TLSHandshakeStart()
13 | }
14 | err := doHandshake(tlsConn, cfg)
15 | if trace.TLSHandshakeDone != nil {
16 | trace.TLSHandshakeDone(tlsConn.ConnectionState(), err)
17 | }
18 | return err
19 | }
20 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/gorilla/websocket/trace_17.go:
--------------------------------------------------------------------------------
1 | // +build !go1.8
2 |
3 | package websocket
4 |
5 | import (
6 | "crypto/tls"
7 | "net/http/httptrace"
8 | )
9 |
10 | func doHandshakeWithTrace(trace *httptrace.ClientTrace, tlsConn *tls.Conn, cfg *tls.Config) error {
11 | return doHandshake(tlsConn, cfg)
12 | }
13 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/spf13/cast/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files, Static and Dynamic libs (Shared Objects)
2 | *.o
3 | *.a
4 | *.so
5 |
6 | # Folders
7 | _obj
8 | _test
9 |
10 | # Architecture specific extensions/prefixes
11 | *.[568vq]
12 | [568vq].out
13 |
14 | *.cgo1.go
15 | *.cgo2.c
16 | _cgo_defun.c
17 | _cgo_gotypes.go
18 | _cgo_export.*
19 |
20 | _testmain.go
21 |
22 | *.exe
23 | *.test
24 |
25 | *.bench
26 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/spf13/cast/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 | env:
3 | - GO111MODULE=on
4 | sudo: required
5 | go:
6 | - "1.11.x"
7 | - tip
8 | os:
9 | - linux
10 | matrix:
11 | allow_failures:
12 | - go: tip
13 | fast_finish: true
14 | script:
15 | - make check
16 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/spf13/cast/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Steve Francia
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.
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/spf13/cast/Makefile:
--------------------------------------------------------------------------------
1 | # A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
2 |
3 | .PHONY: check fmt lint test test-race vet test-cover-html help
4 | .DEFAULT_GOAL := help
5 |
6 | check: test-race fmt vet lint ## Run tests and linters
7 |
8 | test: ## Run tests
9 | go test ./...
10 |
11 | test-race: ## Run tests with race detector
12 | go test -race ./...
13 |
14 | fmt: ## Run gofmt linter
15 | @for d in `go list` ; do \
16 | if [ "`gofmt -l -s $$GOPATH/src/$$d | tee /dev/stderr`" ]; then \
17 | echo "^ improperly formatted go files" && echo && exit 1; \
18 | fi \
19 | done
20 |
21 | lint: ## Run golint linter
22 | @for d in `go list` ; do \
23 | if [ "`golint $$d | tee /dev/stderr`" ]; then \
24 | echo "^ golint errors!" && echo && exit 1; \
25 | fi \
26 | done
27 |
28 | vet: ## Run go vet linter
29 | @if [ "`go vet | tee /dev/stderr`" ]; then \
30 | echo "^ go vet errors!" && echo && exit 1; \
31 | fi
32 |
33 | test-cover-html: ## Generate test coverage report
34 | go test -coverprofile=coverage.out -covermode=count
35 | go tool cover -func=coverage.out
36 |
37 | help:
38 | @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
39 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/spf13/cast/README.md:
--------------------------------------------------------------------------------
1 | cast
2 | ====
3 | [](https://godoc.org/github.com/spf13/cast)
4 | [](https://travis-ci.org/spf13/cast)
5 | [](https://goreportcard.com/report/github.com/spf13/cast)
6 |
7 | Easy and safe casting from one type to another in Go
8 |
9 | Don’t Panic! ... Cast
10 |
11 | ## What is Cast?
12 |
13 | Cast is a library to convert between different go types in a consistent and easy way.
14 |
15 | Cast provides simple functions to easily convert a number to a string, an
16 | interface into a bool, etc. Cast does this intelligently when an obvious
17 | conversion is possible. It doesn’t make any attempts to guess what you meant,
18 | for example you can only convert a string to an int when it is a string
19 | representation of an int such as “8”. Cast was developed for use in
20 | [Hugo](http://hugo.spf13.com), a website engine which uses YAML, TOML or JSON
21 | for meta data.
22 |
23 | ## Why use Cast?
24 |
25 | When working with dynamic data in Go you often need to cast or convert the data
26 | from one type into another. Cast goes beyond just using type assertion (though
27 | it uses that when possible) to provide a very straightforward and convenient
28 | library.
29 |
30 | If you are working with interfaces to handle things like dynamic content
31 | you’ll need an easy way to convert an interface into a given type. This
32 | is the library for you.
33 |
34 | If you are taking in data from YAML, TOML or JSON or other formats which lack
35 | full types, then Cast is the library for you.
36 |
37 | ## Usage
38 |
39 | Cast provides a handful of To_____ methods. These methods will always return
40 | the desired type. **If input is provided that will not convert to that type, the
41 | 0 or nil value for that type will be returned**.
42 |
43 | Cast also provides identical methods To_____E. These return the same result as
44 | the To_____ methods, plus an additional error which tells you if it successfully
45 | converted. Using these methods you can tell the difference between when the
46 | input matched the zero value or when the conversion failed and the zero value
47 | was returned.
48 |
49 | The following examples are merely a sample of what is available. Please review
50 | the code for a complete set.
51 |
52 | ### Example ‘ToString’:
53 |
54 | cast.ToString("mayonegg") // "mayonegg"
55 | cast.ToString(8) // "8"
56 | cast.ToString(8.31) // "8.31"
57 | cast.ToString([]byte("one time")) // "one time"
58 | cast.ToString(nil) // ""
59 |
60 | var foo interface{} = "one more time"
61 | cast.ToString(foo) // "one more time"
62 |
63 |
64 | ### Example ‘ToInt’:
65 |
66 | cast.ToInt(8) // 8
67 | cast.ToInt(8.31) // 8
68 | cast.ToInt("8") // 8
69 | cast.ToInt(true) // 1
70 | cast.ToInt(false) // 0
71 |
72 | var eight interface{} = 8
73 | cast.ToInt(eight) // 8
74 | cast.ToInt(nil) // 0
75 |
76 |
--------------------------------------------------------------------------------
/Futures-Go-demo/_vendor-20190121094707/github.com/spf13/cast/cast.go:
--------------------------------------------------------------------------------
1 | // Copyright © 2014 Steve Francia