committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 1680 additions and 1086 deletions
-
8go.mod
-
31go.sum
-
6vendor/github.com/denisenkom/go-mssqldb/README.md
-
6vendor/github.com/denisenkom/go-mssqldb/appveyor.yml
-
24vendor/github.com/denisenkom/go-mssqldb/buf.go
-
117vendor/github.com/denisenkom/go-mssqldb/bulkcopy.go
-
453vendor/github.com/denisenkom/go-mssqldb/conn_str.go
-
131vendor/github.com/denisenkom/go-mssqldb/decimal.go
-
4vendor/github.com/denisenkom/go-mssqldb/go.mod
-
167vendor/github.com/denisenkom/go-mssqldb/go.sum
-
252vendor/github.com/denisenkom/go-mssqldb/internal/decimal/decimal.go
-
2vendor/github.com/denisenkom/go-mssqldb/mssql_go19.go
-
145vendor/github.com/denisenkom/go-mssqldb/net.go
-
483vendor/github.com/denisenkom/go-mssqldb/tds.go
-
18vendor/github.com/denisenkom/go-mssqldb/types.go
-
6vendor/github.com/denisenkom/go-mssqldb/uniqueidentifier.go
-
73vendor/github.com/golang-sql/civil/CONTRIBUTING.md
-
202vendor/github.com/golang-sql/civil/LICENSE
-
15vendor/github.com/golang-sql/civil/README.md
-
0vendor/github.com/golang-sql/civil/civil.go
-
16vendor/github.com/lafriks/xormstore/go.mod
-
88vendor/github.com/lafriks/xormstore/go.sum
-
189vendor/golang.org/x/crypto/acme/acme.go
-
42vendor/golang.org/x/crypto/acme/autocert/autocert.go
-
20vendor/golang.org/x/crypto/acme/http.go
-
33vendor/golang.org/x/crypto/acme/jws.go
-
122vendor/golang.org/x/crypto/acme/rfc8555.go
-
89vendor/golang.org/x/crypto/acme/types.go
-
10vendor/golang.org/x/crypto/ssh/common.go
-
2vendor/google.golang.org/appengine/internal/net.go
-
12vendor/modules.txt
@ -0,0 +1,453 @@ |
|||
package mssql |
|||
|
|||
import ( |
|||
"fmt" |
|||
"net" |
|||
"net/url" |
|||
"os" |
|||
"strconv" |
|||
"strings" |
|||
"time" |
|||
"unicode" |
|||
) |
|||
|
|||
type connectParams struct { |
|||
logFlags uint64 |
|||
port uint64 |
|||
host string |
|||
instance string |
|||
database string |
|||
user string |
|||
password string |
|||
dial_timeout time.Duration |
|||
conn_timeout time.Duration |
|||
keepAlive time.Duration |
|||
encrypt bool |
|||
disableEncryption bool |
|||
trustServerCertificate bool |
|||
certificate string |
|||
hostInCertificate string |
|||
hostInCertificateProvided bool |
|||
serverSPN string |
|||
workstation string |
|||
appname string |
|||
typeFlags uint8 |
|||
failOverPartner string |
|||
failOverPort uint64 |
|||
packetSize uint16 |
|||
} |
|||
|
|||
func parseConnectParams(dsn string) (connectParams, error) { |
|||
var p connectParams |
|||
|
|||
var params map[string]string |
|||
if strings.HasPrefix(dsn, "odbc:") { |
|||
parameters, err := splitConnectionStringOdbc(dsn[len("odbc:"):]) |
|||
if err != nil { |
|||
return p, err |
|||
} |
|||
params = parameters |
|||
} else if strings.HasPrefix(dsn, "sqlserver://") { |
|||
parameters, err := splitConnectionStringURL(dsn) |
|||
if err != nil { |
|||
return p, err |
|||
} |
|||
params = parameters |
|||
} else { |
|||
params = splitConnectionString(dsn) |
|||
} |
|||
|
|||
strlog, ok := params["log"] |
|||
if ok { |
|||
var err error |
|||
p.logFlags, err = strconv.ParseUint(strlog, 10, 64) |
|||
if err != nil { |
|||
return p, fmt.Errorf("Invalid log parameter '%s': %s", strlog, err.Error()) |
|||
} |
|||
} |
|||
server := params["server"] |
|||
parts := strings.SplitN(server, `\`, 2) |
|||
p.host = parts[0] |
|||
if p.host == "." || strings.ToUpper(p.host) == "(LOCAL)" || p.host == "" { |
|||
p.host = "localhost" |
|||
} |
|||
if len(parts) > 1 { |
|||
p.instance = parts[1] |
|||
} |
|||
p.database = params["database"] |
|||
p.user = params["user id"] |
|||
p.password = params["password"] |
|||
|
|||
p.port = 1433 |
|||
strport, ok := params["port"] |
|||
if ok { |
|||
var err error |
|||
p.port, err = strconv.ParseUint(strport, 10, 16) |
|||
if err != nil { |
|||
f := "Invalid tcp port '%v': %v" |
|||
return p, fmt.Errorf(f, strport, err.Error()) |
|||
} |
|||
} |
|||
|
|||
// https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-the-network-packet-size-server-configuration-option
|
|||
// Default packet size remains at 4096 bytes
|
|||
p.packetSize = 4096 |
|||
strpsize, ok := params["packet size"] |
|||
if ok { |
|||
var err error |
|||
psize, err := strconv.ParseUint(strpsize, 0, 16) |
|||
if err != nil { |
|||
f := "Invalid packet size '%v': %v" |
|||
return p, fmt.Errorf(f, strpsize, err.Error()) |
|||
} |
|||
|
|||
// Ensure packet size falls within the TDS protocol range of 512 to 32767 bytes
|
|||
// NOTE: Encrypted connections have a maximum size of 16383 bytes. If you request
|
|||
// a higher packet size, the server will respond with an ENVCHANGE request to
|
|||
// alter the packet size to 16383 bytes.
|
|||
p.packetSize = uint16(psize) |
|||
if p.packetSize < 512 { |
|||
p.packetSize = 512 |
|||
} else if p.packetSize > 32767 { |
|||
p.packetSize = 32767 |
|||
} |
|||
} |
|||
|
|||
// https://msdn.microsoft.com/en-us/library/dd341108.aspx
|
|||
//
|
|||
// Do not set a connection timeout. Use Context to manage such things.
|
|||
// Default to zero, but still allow it to be set.
|
|||
if strconntimeout, ok := params["connection timeout"]; ok { |
|||
timeout, err := strconv.ParseUint(strconntimeout, 10, 64) |
|||
if err != nil { |
|||
f := "Invalid connection timeout '%v': %v" |
|||
return p, fmt.Errorf(f, strconntimeout, err.Error()) |
|||
} |
|||
p.conn_timeout = time.Duration(timeout) * time.Second |
|||
} |
|||
p.dial_timeout = 15 * time.Second |
|||
if strdialtimeout, ok := params["dial timeout"]; ok { |
|||
timeout, err := strconv.ParseUint(strdialtimeout, 10, 64) |
|||
if err != nil { |
|||
f := "Invalid dial timeout '%v': %v" |
|||
return p, fmt.Errorf(f, strdialtimeout, err.Error()) |
|||
} |
|||
p.dial_timeout = time.Duration(timeout) * time.Second |
|||
} |
|||
|
|||
// default keep alive should be 30 seconds according to spec:
|
|||
// https://msdn.microsoft.com/en-us/library/dd341108.aspx
|
|||
p.keepAlive = 30 * time.Second |
|||
if keepAlive, ok := params["keepalive"]; ok { |
|||
timeout, err := strconv.ParseUint(keepAlive, 10, 64) |
|||
if err != nil { |
|||
f := "Invalid keepAlive value '%s': %s" |
|||
return p, fmt.Errorf(f, keepAlive, err.Error()) |
|||
} |
|||
p.keepAlive = time.Duration(timeout) * time.Second |
|||
} |
|||
encrypt, ok := params["encrypt"] |
|||
if ok { |
|||
if strings.EqualFold(encrypt, "DISABLE") { |
|||
p.disableEncryption = true |
|||
} else { |
|||
var err error |
|||
p.encrypt, err = strconv.ParseBool(encrypt) |
|||
if err != nil { |
|||
f := "Invalid encrypt '%s': %s" |
|||
return p, fmt.Errorf(f, encrypt, err.Error()) |
|||
} |
|||
} |
|||
} else { |
|||
p.trustServerCertificate = true |
|||
} |
|||
trust, ok := params["trustservercertificate"] |
|||
if ok { |
|||
var err error |
|||
p.trustServerCertificate, err = strconv.ParseBool(trust) |
|||
if err != nil { |
|||
f := "Invalid trust server certificate '%s': %s" |
|||
return p, fmt.Errorf(f, trust, err.Error()) |
|||
} |
|||
} |
|||
p.certificate = params["certificate"] |
|||
p.hostInCertificate, ok = params["hostnameincertificate"] |
|||
if ok { |
|||
p.hostInCertificateProvided = true |
|||
} else { |
|||
p.hostInCertificate = p.host |
|||
p.hostInCertificateProvided = false |
|||
} |
|||
|
|||
serverSPN, ok := params["serverspn"] |
|||
if ok { |
|||
p.serverSPN = serverSPN |
|||
} else { |
|||
p.serverSPN = fmt.Sprintf("MSSQLSvc/%s:%d", p.host, p.port) |
|||
} |
|||
|
|||
workstation, ok := params["workstation id"] |
|||
if ok { |
|||
p.workstation = workstation |
|||
} else { |
|||
workstation, err := os.Hostname() |
|||
if err == nil { |
|||
p.workstation = workstation |
|||
} |
|||
} |
|||
|
|||
appname, ok := params["app name"] |
|||
if !ok { |
|||
appname = "go-mssqldb" |
|||
} |
|||
p.appname = appname |
|||
|
|||
appintent, ok := params["applicationintent"] |
|||
if ok { |
|||
if appintent == "ReadOnly" { |
|||
p.typeFlags |= fReadOnlyIntent |
|||
} |
|||
} |
|||
|
|||
failOverPartner, ok := params["failoverpartner"] |
|||
if ok { |
|||
p.failOverPartner = failOverPartner |
|||
} |
|||
|
|||
failOverPort, ok := params["failoverport"] |
|||
if ok { |
|||
var err error |
|||
p.failOverPort, err = strconv.ParseUint(failOverPort, 0, 16) |
|||
if err != nil { |
|||
f := "Invalid tcp port '%v': %v" |
|||
return p, fmt.Errorf(f, failOverPort, err.Error()) |
|||
} |
|||
} |
|||
|
|||
return p, nil |
|||
} |
|||
|
|||
func splitConnectionString(dsn string) (res map[string]string) { |
|||
res = map[string]string{} |
|||
parts := strings.Split(dsn, ";") |
|||
for _, part := range parts { |
|||
if len(part) == 0 { |
|||
continue |
|||
} |
|||
lst := strings.SplitN(part, "=", 2) |
|||
name := strings.TrimSpace(strings.ToLower(lst[0])) |
|||
if len(name) == 0 { |
|||
continue |
|||
} |
|||
var value string = "" |
|||
if len(lst) > 1 { |
|||
value = strings.TrimSpace(lst[1]) |
|||
} |
|||
res[name] = value |
|||
} |
|||
return res |
|||
} |
|||
|
|||
// Splits a URL of the form sqlserver://username:password@host/instance?param1=value¶m2=value
|
|||
func splitConnectionStringURL(dsn string) (map[string]string, error) { |
|||
res := map[string]string{} |
|||
|
|||
u, err := url.Parse(dsn) |
|||
if err != nil { |
|||
return res, err |
|||
} |
|||
|
|||
if u.Scheme != "sqlserver" { |
|||
return res, fmt.Errorf("scheme %s is not recognized", u.Scheme) |
|||
} |
|||
|
|||
if u.User != nil { |
|||
res["user id"] = u.User.Username() |
|||
p, exists := u.User.Password() |
|||
if exists { |
|||
res["password"] = p |
|||
} |
|||
} |
|||
|
|||
host, port, err := net.SplitHostPort(u.Host) |
|||
if err != nil { |
|||
host = u.Host |
|||
} |
|||
|
|||
if len(u.Path) > 0 { |
|||
res["server"] = host + "\\" + u.Path[1:] |
|||
} else { |
|||
res["server"] = host |
|||
} |
|||
|
|||
if len(port) > 0 { |
|||
res["port"] = port |
|||
} |
|||
|
|||
query := u.Query() |
|||
for k, v := range query { |
|||
if len(v) > 1 { |
|||
return res, fmt.Errorf("key %s provided more than once", k) |
|||
} |
|||
res[strings.ToLower(k)] = v[0] |
|||
} |
|||
|
|||
return res, nil |
|||
} |
|||
|
|||
// Splits a URL in the ODBC format
|
|||
func splitConnectionStringOdbc(dsn string) (map[string]string, error) { |
|||
res := map[string]string{} |
|||
|
|||
type parserState int |
|||
const ( |
|||
// Before the start of a key
|
|||
parserStateBeforeKey parserState = iota |
|||
|
|||
// Inside a key
|
|||
parserStateKey |
|||
|
|||
// Beginning of a value. May be bare or braced
|
|||
parserStateBeginValue |
|||
|
|||
// Inside a bare value
|
|||
parserStateBareValue |
|||
|
|||
// Inside a braced value
|
|||
parserStateBracedValue |
|||
|
|||
// A closing brace inside a braced value.
|
|||
// May be the end of the value or an escaped closing brace, depending on the next character
|
|||
parserStateBracedValueClosingBrace |
|||
|
|||
// After a value. Next character should be a semicolon or whitespace.
|
|||
parserStateEndValue |
|||
) |
|||
|
|||
var state = parserStateBeforeKey |
|||
|
|||
var key string |
|||
var value string |
|||
|
|||
for i, c := range dsn { |
|||
switch state { |
|||
case parserStateBeforeKey: |
|||
switch { |
|||
case c == '=': |
|||
return res, fmt.Errorf("Unexpected character = at index %d. Expected start of key or semi-colon or whitespace.", i) |
|||
case !unicode.IsSpace(c) && c != ';': |
|||
state = parserStateKey |
|||
key += string(c) |
|||
} |
|||
|
|||
case parserStateKey: |
|||
switch c { |
|||
case '=': |
|||
key = normalizeOdbcKey(key) |
|||
state = parserStateBeginValue |
|||
|
|||
case ';': |
|||
// Key without value
|
|||
key = normalizeOdbcKey(key) |
|||
res[key] = value |
|||
key = "" |
|||
value = "" |
|||
state = parserStateBeforeKey |
|||
|
|||
default: |
|||
key += string(c) |
|||
} |
|||
|
|||
case parserStateBeginValue: |
|||
switch { |
|||
case c == '{': |
|||
state = parserStateBracedValue |
|||
case c == ';': |
|||
// Empty value
|
|||
res[key] = value |
|||
key = "" |
|||
state = parserStateBeforeKey |
|||
case unicode.IsSpace(c): |
|||
// Ignore whitespace
|
|||
default: |
|||
state = parserStateBareValue |
|||
value += string(c) |
|||
} |
|||
|
|||
case parserStateBareValue: |
|||
if c == ';' { |
|||
res[key] = strings.TrimRightFunc(value, unicode.IsSpace) |
|||
key = "" |
|||
value = "" |
|||
state = parserStateBeforeKey |
|||
} else { |
|||
value += string(c) |
|||
} |
|||
|
|||
case parserStateBracedValue: |
|||
if c == '}' { |
|||
state = parserStateBracedValueClosingBrace |
|||
} else { |
|||
value += string(c) |
|||
} |
|||
|
|||
case parserStateBracedValueClosingBrace: |
|||
if c == '}' { |
|||
// Escaped closing brace
|
|||
value += string(c) |
|||
state = parserStateBracedValue |
|||
continue |
|||
} |
|||
|
|||
// End of braced value
|
|||
res[key] = value |
|||
key = "" |
|||
value = "" |
|||
|
|||
// This character is the first character past the end,
|
|||
// so it needs to be parsed like the parserStateEndValue state.
|
|||
state = parserStateEndValue |
|||
switch { |
|||
case c == ';': |
|||
state = parserStateBeforeKey |
|||
case unicode.IsSpace(c): |
|||
// Ignore whitespace
|
|||
default: |
|||
return res, fmt.Errorf("Unexpected character %c at index %d. Expected semi-colon or whitespace.", c, i) |
|||
} |
|||
|
|||
case parserStateEndValue: |
|||
switch { |
|||
case c == ';': |
|||
state = parserStateBeforeKey |
|||
case unicode.IsSpace(c): |
|||
// Ignore whitespace
|
|||
default: |
|||
return res, fmt.Errorf("Unexpected character %c at index %d. Expected semi-colon or whitespace.", c, i) |
|||
} |
|||
} |
|||
} |
|||
|
|||
switch state { |
|||
case parserStateBeforeKey: // Okay
|
|||
case parserStateKey: // Unfinished key. Treat as key without value.
|
|||
key = normalizeOdbcKey(key) |
|||
res[key] = value |
|||
case parserStateBeginValue: // Empty value
|
|||
res[key] = value |
|||
case parserStateBareValue: |
|||
res[key] = strings.TrimRightFunc(value, unicode.IsSpace) |
|||
case parserStateBracedValue: |
|||
return res, fmt.Errorf("Unexpected end of braced value at index %d.", len(dsn)) |
|||
case parserStateBracedValueClosingBrace: // End of braced value
|
|||
res[key] = value |
|||
case parserStateEndValue: // Okay
|
|||
} |
|||
|
|||
return res, nil |
|||
} |
|||
|
|||
// Normalizes the given string as an ODBC-format key
|
|||
func normalizeOdbcKey(s string) string { |
|||
return strings.ToLower(strings.TrimRightFunc(s, unicode.IsSpace)) |
|||
} |
@ -1,131 +0,0 @@ |
|||
package mssql |
|||
|
|||
import ( |
|||
"encoding/binary" |
|||
"errors" |
|||
"math" |
|||
"math/big" |
|||
) |
|||
|
|||
// http://msdn.microsoft.com/en-us/library/ee780893.aspx
|
|||
type Decimal struct { |
|||
integer [4]uint32 |
|||
positive bool |
|||
prec uint8 |
|||
scale uint8 |
|||
} |
|||
|
|||
var scaletblflt64 [39]float64 |
|||
|
|||
func (d Decimal) ToFloat64() float64 { |
|||
val := float64(0) |
|||
for i := 3; i >= 0; i-- { |
|||
val *= 0x100000000 |
|||
val += float64(d.integer[i]) |
|||
} |
|||
if !d.positive { |
|||
val = -val |
|||
} |
|||
if d.scale != 0 { |
|||
val /= scaletblflt64[d.scale] |
|||
} |
|||
return val |
|||
} |
|||
|
|||
const autoScale = 100 |
|||
|
|||
func Float64ToDecimal(f float64) (Decimal, error) { |
|||
return Float64ToDecimalScale(f, autoScale) |
|||
} |
|||
|
|||
func Float64ToDecimalScale(f float64, scale uint8) (Decimal, error) { |
|||
var dec Decimal |
|||
if math.IsNaN(f) { |
|||
return dec, errors.New("NaN") |
|||
} |
|||
if math.IsInf(f, 0) { |
|||
return dec, errors.New("Infinity can't be converted to decimal") |
|||
} |
|||
dec.positive = f >= 0 |
|||
if !dec.positive { |
|||
f = math.Abs(f) |
|||
} |
|||
if f > 3.402823669209385e+38 { |
|||
return dec, errors.New("Float value is out of range") |
|||
} |
|||
dec.prec = 20 |
|||
var integer float64 |
|||
for dec.scale = 0; dec.scale <= scale; dec.scale++ { |
|||
integer = f * scaletblflt64[dec.scale] |
|||
_, frac := math.Modf(integer) |
|||
if frac == 0 && scale == autoScale { |
|||
break |
|||
} |
|||
} |
|||
for i := 0; i < 4; i++ { |
|||
mod := math.Mod(integer, 0x100000000) |
|||
integer -= mod |
|||
integer /= 0x100000000 |
|||
dec.integer[i] = uint32(mod) |
|||
} |
|||
return dec, nil |
|||
} |
|||
|
|||
func init() { |
|||
var acc float64 = 1 |
|||
for i := 0; i <= 38; i++ { |
|||
scaletblflt64[i] = acc |
|||
acc *= 10 |
|||
} |
|||
} |
|||
|
|||
func (d Decimal) BigInt() big.Int { |
|||
bytes := make([]byte, 16) |
|||
binary.BigEndian.PutUint32(bytes[0:4], d.integer[3]) |
|||
binary.BigEndian.PutUint32(bytes[4:8], d.integer[2]) |
|||
binary.BigEndian.PutUint32(bytes[8:12], d.integer[1]) |
|||
binary.BigEndian.PutUint32(bytes[12:16], d.integer[0]) |
|||
var x big.Int |
|||
x.SetBytes(bytes) |
|||
if !d.positive { |
|||
x.Neg(&x) |
|||
} |
|||
return x |
|||
} |
|||
|
|||
func (d Decimal) Bytes() []byte { |
|||
x := d.BigInt() |
|||
return scaleBytes(x.String(), d.scale) |
|||
} |
|||
|
|||
func (d Decimal) UnscaledBytes() []byte { |
|||
x := d.BigInt() |
|||
return x.Bytes() |
|||
} |
|||
|
|||
func scaleBytes(s string, scale uint8) []byte { |
|||
z := make([]byte, 0, len(s)+1) |
|||
if s[0] == '-' || s[0] == '+' { |
|||
z = append(z, byte(s[0])) |
|||
s = s[1:] |
|||
} |
|||
pos := len(s) - int(scale) |
|||
if pos <= 0 { |
|||
z = append(z, byte('0')) |
|||
} else if pos > 0 { |
|||
z = append(z, []byte(s[:pos])...) |
|||
} |
|||
if scale > 0 { |
|||
z = append(z, byte('.')) |
|||
for pos < 0 { |
|||
z = append(z, byte('0')) |
|||
pos++ |
|||
} |
|||
z = append(z, []byte(s[pos:])...) |
|||
} |
|||
return z |
|||
} |
|||
|
|||
func (d Decimal) String() string { |
|||
return string(d.Bytes()) |
|||
} |
@ -1,168 +1,5 @@ |
|||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= |
|||
cloud.google.com/go v0.31.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= |
|||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= |
|||
cloud.google.com/go v0.37.2 h1:4y4L7BdHenTfZL0HervofNTHh9Ad6mNX72cQvl+5eH0= |
|||
cloud.google.com/go v0.37.2/go.mod h1:H8IAquKe2L30IxoupDgqTaQvKSwF/c8prYHynGIWQbA= |
|||
git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= |
|||
git.apache.org/thrift.git v0.12.0/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= |
|||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= |
|||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= |
|||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= |
|||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= |
|||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= |
|||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= |
|||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= |
|||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= |
|||
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= |
|||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= |
|||
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= |
|||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
|||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= |
|||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= |
|||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= |
|||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= |
|||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= |
|||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= |
|||
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= |
|||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= |
|||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= |
|||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= |
|||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= |
|||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= |
|||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= |
|||
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= |
|||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= |
|||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= |
|||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= |
|||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= |
|||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= |
|||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= |
|||
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= |
|||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= |
|||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= |
|||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= |
|||
github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= |
|||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= |
|||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= |
|||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= |
|||
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= |
|||
github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= |
|||
github.com/grpc-ecosystem/grpc-gateway v1.6.2/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= |
|||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= |
|||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= |
|||
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= |
|||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= |
|||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= |
|||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= |
|||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= |
|||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= |
|||
github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= |
|||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= |
|||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= |
|||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= |
|||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= |
|||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= |
|||
github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= |
|||
github.com/openzipkin/zipkin-go v0.1.3/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= |
|||
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= |
|||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= |
|||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= |
|||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
|||
github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= |
|||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= |
|||
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= |
|||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= |
|||
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= |
|||
github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= |
|||
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= |
|||
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= |
|||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= |
|||
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= |
|||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= |
|||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= |
|||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= |
|||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= |
|||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= |
|||
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= |
|||
go.opencensus.io v0.19.1/go.mod h1:gug0GbSHa8Pafr0d2urOSgoXHZ6x/RUlaiT0d9pqb4A= |
|||
go.opencensus.io v0.19.2/go.mod h1:NO/8qkisMZLZ1FCsKNqtJPwc8/TaclWyY0B6wcYNg9M= |
|||
go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= |
|||
golang.org/x/build v0.0.0-20190314133821-5284462c4bec/go.mod h1:atTaCNAy0f16Ah5aV1gMSwgiKVHwu/JncqDpuRr7lS4= |
|||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= |
|||
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= |
|||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= |
|||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= |
|||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= |
|||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI= |
|||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= |
|||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= |
|||
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= |
|||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= |
|||
golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= |
|||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= |
|||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= |
|||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20181029044818-c44066c5c816/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= |
|||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= |
|||
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= |
|||
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= |
|||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= |
|||
golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= |
|||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
|||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
|||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
|||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
|||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20181218192612-074acd46bca6/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
|||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
|||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
|||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= |
|||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
|||
golang.org/x/tools v0.0.0-20181219222714-6e267b5cc78e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
|||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
|||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= |
|||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= |
|||
google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= |
|||
google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= |
|||
google.golang.org/api v0.0.0-20181220000619-583d854617af/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= |
|||
google.golang.org/api v0.2.0/go.mod h1:IfRCZScioGtypHNTlz3gFk67J8uePVW7uDTBzXuIkhU= |
|||
google.golang.org/api v0.3.0/go.mod h1:IuvZyQh8jgscv8qWfQ4ABd8m7hEudgBFM/EdhA3BnXw= |
|||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= |
|||
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= |
|||
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= |
|||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= |
|||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= |
|||
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= |
|||
google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= |
|||
google.golang.org/genproto v0.0.0-20181219182458-5a97ab628bfb/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= |
|||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= |
|||
google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= |
|||
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= |
|||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= |
|||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= |
|||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= |
|||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
|||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
|||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= |
|||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= |
|||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= |
|||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
|||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
|||
grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= |
|||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= |
|||
honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= |
|||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= |
|||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= |
@ -0,0 +1,252 @@ |
|||
package decimal |
|||
|
|||
import ( |
|||
"encoding/binary" |
|||
"errors" |
|||
"fmt" |
|||
"math" |
|||
"math/big" |
|||
"strings" |
|||
) |
|||
|
|||
// Decimal represents decimal type in the Microsoft Open Specifications: http://msdn.microsoft.com/en-us/library/ee780893.aspx
|
|||
type Decimal struct { |
|||
integer [4]uint32 // Little-endian
|
|||
positive bool |
|||
prec uint8 |
|||
scale uint8 |
|||
} |
|||
|
|||
var ( |
|||
scaletblflt64 [39]float64 |
|||
int10 big.Int |
|||
int1e5 big.Int |
|||
) |
|||
|
|||
func init() { |
|||
var acc float64 = 1 |
|||
for i := 0; i <= 38; i++ { |
|||
scaletblflt64[i] = acc |
|||
acc *= 10 |
|||
} |
|||
|
|||
int10.SetInt64(10) |
|||
int1e5.SetInt64(1e5) |
|||
} |
|||
|
|||
const autoScale = 100 |
|||
|
|||
// SetInteger sets the ind'th element in the integer array
|
|||
func (d *Decimal) SetInteger(integer uint32, ind uint8) { |
|||
d.integer[ind] = integer |
|||
} |
|||
|
|||
// SetPositive sets the positive member
|
|||
func (d *Decimal) SetPositive(positive bool) { |
|||
d.positive = positive |
|||
} |
|||
|
|||
// SetPrec sets the prec member
|
|||
func (d *Decimal) SetPrec(prec uint8) { |
|||
d.prec = prec |
|||
} |
|||
|
|||
// SetScale sets the scale member
|
|||
func (d *Decimal) SetScale(scale uint8) { |
|||
d.scale = scale |
|||
} |
|||
|
|||
// IsPositive returns true if the Decimal is positive
|
|||
func (d *Decimal) IsPositive() bool { |
|||
return d.positive |
|||
} |
|||
|
|||
// ToFloat64 converts decimal to a float64
|
|||
func (d Decimal) ToFloat64() float64 { |
|||
val := float64(0) |
|||
for i := 3; i >= 0; i-- { |
|||
val *= 0x100000000 |
|||
val += float64(d.integer[i]) |
|||
} |
|||
if !d.positive { |
|||
val = -val |
|||
} |
|||
if d.scale != 0 { |
|||
val /= scaletblflt64[d.scale] |
|||
} |
|||
return val |
|||
} |
|||
|
|||
// BigInt converts decimal to a bigint
|
|||
func (d Decimal) BigInt() big.Int { |
|||
bytes := make([]byte, 16) |
|||
binary.BigEndian.PutUint32(bytes[0:4], d.integer[3]) |
|||
binary.BigEndian.PutUint32(bytes[4:8], d.integer[2]) |
|||
binary.BigEndian.PutUint32(bytes[8:12], d.integer[1]) |
|||
binary.BigEndian.PutUint32(bytes[12:16], d.integer[0]) |
|||
var x big.Int |
|||
x.SetBytes(bytes) |
|||
if !d.positive { |
|||
x.Neg(&x) |
|||
} |
|||
return x |
|||
} |
|||
|
|||
// Bytes converts decimal to a scaled byte slice
|
|||
func (d Decimal) Bytes() []byte { |
|||
x := d.BigInt() |
|||
return ScaleBytes(x.String(), d.scale) |
|||
} |
|||
|
|||
// UnscaledBytes converts decimal to a unscaled byte slice
|
|||
func (d Decimal) UnscaledBytes() []byte { |
|||
x := d.BigInt() |
|||
return x.Bytes() |
|||
} |
|||
|
|||
// String converts decimal to a string
|
|||
func (d Decimal) String() string { |
|||
return string(d.Bytes()) |
|||
} |
|||
|
|||
// Float64ToDecimal converts float64 to decimal
|
|||
func Float64ToDecimal(f float64) (Decimal, error) { |
|||
return Float64ToDecimalScale(f, autoScale) |
|||
} |
|||
|
|||
// Float64ToDecimalScale converts float64 to decimal; user can specify the scale
|
|||
func Float64ToDecimalScale(f float64, scale uint8) (Decimal, error) { |
|||
var dec Decimal |
|||
if math.IsNaN(f) { |
|||
return dec, errors.New("NaN") |
|||
} |
|||
if math.IsInf(f, 0) { |
|||
return dec, errors.New("Infinity can't be converted to decimal") |
|||
} |
|||
dec.positive = f >= 0 |
|||
if !dec.positive { |
|||
f = math.Abs(f) |
|||
} |
|||
if f > 3.402823669209385e+38 { |
|||
return dec, errors.New("Float value is out of range") |
|||
} |
|||
dec.prec = 20 |
|||
var integer float64 |
|||
for dec.scale = 0; dec.scale <= scale; dec.scale++ { |
|||
integer = f * scaletblflt64[dec.scale] |
|||
_, frac := math.Modf(integer) |
|||
if frac == 0 && scale == autoScale { |
|||
break |
|||
} |
|||
} |
|||
for i := 0; i < 4; i++ { |
|||
mod := math.Mod(integer, 0x100000000) |
|||
integer -= mod |
|||
integer /= 0x100000000 |
|||
dec.integer[i] = uint32(mod) |
|||
if mod-math.Trunc(mod) >= 0.5 { |
|||
dec.integer[i] = uint32(mod) + 1 |
|||
} |
|||
} |
|||
return dec, nil |
|||
} |
|||
|
|||
// Int64ToDecimalScale converts float64 to decimal; user can specify the scale
|
|||
func Int64ToDecimalScale(v int64, scale uint8) Decimal { |
|||
positive := v >= 0 |
|||
if !positive { |
|||
if v == math.MinInt64 { |
|||
// Special case - can't negate
|
|||
return Decimal{ |
|||
integer: [4]uint32{0, 0x80000000, 0, 0}, |
|||
positive: false, |
|||
prec: 20, |
|||
scale: 0, |
|||
} |
|||
} |
|||
v = -v |
|||
} |
|||
return Decimal{ |
|||
integer: [4]uint32{uint32(v), uint32(v >> 32), 0, 0}, |
|||
positive: positive, |
|||
prec: 20, |
|||
scale: scale, |
|||
} |
|||
} |
|||
|
|||
// StringToDecimalScale converts string to decimal
|
|||
func StringToDecimalScale(v string, outScale uint8) (Decimal, error) { |
|||
var r big.Int |
|||
var unscaled string |
|||
var inScale int |
|||
|
|||
point := strings.LastIndexByte(v, '.') |
|||
if point == -1 { |
|||
inScale = 0 |
|||
unscaled = v |
|||
} else { |
|||
inScale = len(v) - point - 1 |
|||
unscaled = v[:point] + v[point+1:] |
|||
} |
|||
if inScale > math.MaxUint8 { |
|||
return Decimal{}, fmt.Errorf("can't parse %q as a decimal number: scale too large", v) |
|||
} |
|||
|
|||
_, ok := r.SetString(unscaled, 10) |
|||
if !ok { |
|||
return Decimal{}, fmt.Errorf("can't parse %q as a decimal number", v) |
|||
} |
|||
|
|||
if inScale > int(outScale) { |
|||
return Decimal{}, fmt.Errorf("can't parse %q as a decimal number: scale %d is larger than the scale %d of the target column", v, inScale, outScale) |
|||
} |
|||
for inScale < int(outScale) { |
|||
if int(outScale)-inScale >= 5 { |
|||
r.Mul(&r, &int1e5) |
|||
inScale += 5 |
|||
} else { |
|||
r.Mul(&r, &int10) |
|||
inScale++ |
|||
} |
|||
} |
|||
|
|||
bytes := r.Bytes() |
|||
if len(bytes) > 16 { |
|||
return Decimal{}, fmt.Errorf("can't parse %q as a decimal number: precision too large", v) |
|||
} |
|||
var out [4]uint32 |
|||
for i, b := range bytes { |
|||
pos := len(bytes) - i - 1 |
|||
out[pos/4] += uint32(b) << uint(pos%4*8) |
|||
} |
|||
return Decimal{ |
|||
integer: out, |
|||
positive: r.Sign() >= 0, |
|||
prec: 20, |
|||
scale: uint8(inScale), |
|||
}, nil |
|||
} |
|||
|
|||
// ScaleBytes converts a stringified decimal to a scaled byte slice
|
|||
func ScaleBytes(s string, scale uint8) []byte { |
|||
z := make([]byte, 0, len(s)+1) |
|||
if s[0] == '-' || s[0] == '+' { |
|||
z = append(z, byte(s[0])) |
|||
s = s[1:] |
|||
} |
|||
pos := len(s) - int(scale) |
|||
if pos <= 0 { |
|||
z = append(z, byte('0')) |
|||
} else if pos > 0 { |
|||
z = append(z, []byte(s[:pos])...) |
|||
} |
|||
if scale > 0 { |
|||
z = append(z, byte('.')) |
|||
for pos < 0 { |
|||
z = append(z, byte('0')) |
|||
pos++ |
|||
} |
|||
z = append(z, []byte(s[pos:])...) |
|||
} |
|||
return z |
|||
} |