From 1bcb5ac28fd7a93291da4e18bb13479b648637b3 Mon Sep 17 00:00:00 2001 From: Hunter Blanks Date: Mon, 6 Jul 2020 12:16:16 -0700 Subject: [PATCH 1/2] Remove vendor/ & replace with go mod --- go.mod | 9 + go.sum | 17 ++ .../github.com/segmentio/backo-go/.gitmodules | 3 - .../github.com/segmentio/backo-go/README.md | 80 ------- vendor/github.com/segmentio/backo-go/backo.go | 83 ------- vendor/github.com/xtgo/uuid/AUTHORS | 5 - vendor/github.com/xtgo/uuid/LICENSE | 27 --- vendor/github.com/xtgo/uuid/uuid.go | 204 ------------------ 8 files changed, 26 insertions(+), 402 deletions(-) create mode 100644 go.mod create mode 100644 go.sum delete mode 100644 vendor/github.com/segmentio/backo-go/.gitmodules delete mode 100644 vendor/github.com/segmentio/backo-go/README.md delete mode 100644 vendor/github.com/segmentio/backo-go/backo.go delete mode 100644 vendor/github.com/xtgo/uuid/AUTHORS delete mode 100644 vendor/github.com/xtgo/uuid/LICENSE delete mode 100644 vendor/github.com/xtgo/uuid/uuid.go diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..c720ffb --- /dev/null +++ b/go.mod @@ -0,0 +1,9 @@ +module github.com/segmentio/analytics-go + +go 1.14 + +require ( + github.com/segmentio/backo-go v0.0.0-20200129164019-23eae7c10bd3 + github.com/segmentio/conf v1.2.0 + github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..5aed5bb --- /dev/null +++ b/go.sum @@ -0,0 +1,17 @@ +github.com/segmentio/backo-go v0.0.0-20200129164019-23eae7c10bd3 h1:ZuhckGJ10ulaKkdvJtiAqsLTiPrLaXSdnVgXJKJkTxE= +github.com/segmentio/backo-go v0.0.0-20200129164019-23eae7c10bd3/go.mod h1:9/Rh6yILuLysoQnZ2oNooD2g7aBnvM7r/fNVxRNWfBc= +github.com/segmentio/conf v1.2.0 h1:5OT9+6OyVHLsFLsiJa/2KlqiA1m7mpdUBlkB/qYTMts= +github.com/segmentio/conf v1.2.0/go.mod h1:Y3B9O/PqqWqjyxyWWseyj/quPEtMu1zDp/kVbSWWaB0= +github.com/segmentio/go-snakecase v1.1.0 h1:ZJO4SNKKV0MjGOv0LHnixxN5FYv1JKBnVXEuBpwcbQI= +github.com/segmentio/go-snakecase v1.1.0/go.mod h1:jk1miR5MS7Na32PZUykG89Arm+1BUSYhuGR6b7+hJto= +github.com/segmentio/objconv v1.0.1 h1:QjfLzwriJj40JibCV3MGSEiAoXixbp4ybhwfTB8RXOM= +github.com/segmentio/objconv v1.0.1/go.mod h1:auayaH5k3137Cl4SoXTgrzQcuQDmvuVtZgS0fb1Ahys= +github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c h1:3lbZUMbMiGUW/LMkfsEABsc5zNT9+b1CvsJx47JzJ8g= +github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c/go.mod h1:UrdRz5enIKZ63MEE3IF9l2/ebyx59GyGgPi+tICQdmM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/go-playground/mold.v2 v2.2.0 h1:Y4IYB4/HYQfuq43zaKh6vs9cVelLE9qbqe2fkyfCTWQ= +gopkg.in/go-playground/mold.v2 v2.2.0/go.mod h1:XMyyRsGtakkDPbxXbrA5VODo6bUXyvoDjLd5l3T0XoA= +gopkg.in/validator.v2 v2.0.0-20180514200540-135c24b11c19 h1:WB265cn5OpO+hK3pikC9hpP1zI/KTwmyMFKloW9eOVc= +gopkg.in/validator.v2 v2.0.0-20180514200540-135c24b11c19/go.mod h1:o4V0GXN9/CAmCsvJ0oXYZvrZOe7syiDZSN1GWGZTGzc= +gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/segmentio/backo-go/.gitmodules b/vendor/github.com/segmentio/backo-go/.gitmodules deleted file mode 100644 index 36de929..0000000 --- a/vendor/github.com/segmentio/backo-go/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "vendor/github.com/bmizerany/assert"] - path = vendor/github.com/bmizerany/assert - url = https://github.com/bmizerany/assert diff --git a/vendor/github.com/segmentio/backo-go/README.md b/vendor/github.com/segmentio/backo-go/README.md deleted file mode 100644 index 1362bec..0000000 --- a/vendor/github.com/segmentio/backo-go/README.md +++ /dev/null @@ -1,80 +0,0 @@ -Backo [![GoDoc](http://godoc.org/github.com/segmentio/backo-go?status.png)](http://godoc.org/github.com/segmentio/backo-go) ------ - -Exponential backoff for Go (Go port of segmentio/backo). - - -Usage ------ - -```go -import "github.com/segmentio/backo-go" - -// Create a Backo instance. -backo := backo.NewBacko(milliseconds(100), 2, 1, milliseconds(10*1000)) -// OR with defaults. -backo := backo.DefaultBacko() - -// Use the ticker API. -ticker := b.NewTicker() -for { - timeout := time.After(5 * time.Minute) - select { - case <-ticker.C: - fmt.Println("ticked") - case <- timeout: - fmt.Println("timed out") - } -} - -// Or simply work with backoff intervals directly. -for i := 0; i < n; i++ { - // Sleep the current goroutine. - backo.Sleep(i) - // Retrieve the duration manually. - duration := backo.Duration(i) -} -``` - -License -------- - -``` -WWWWWW||WWWWWW - W W W||W W W - || - ( OO )__________ - / | \ - /o o| MIT \ - \___/||_||__||_|| * - || || || || - _||_|| _||_|| - (__|__|(__|__| - -The MIT License (MIT) - -Copyright (c) 2015 Segment, Inc. - -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: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -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. -``` - - - - [1]: http://github.com/segmentio/backo-java - [2]: http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.segment.backo&a=backo&v=LATEST \ No newline at end of file diff --git a/vendor/github.com/segmentio/backo-go/backo.go b/vendor/github.com/segmentio/backo-go/backo.go deleted file mode 100644 index 6f7b6d5..0000000 --- a/vendor/github.com/segmentio/backo-go/backo.go +++ /dev/null @@ -1,83 +0,0 @@ -package backo - -import ( - "math" - "math/rand" - "time" -) - -type Backo struct { - base time.Duration - factor uint8 - jitter float64 - cap time.Duration -} - -// Creates a backo instance with the given parameters -func NewBacko(base time.Duration, factor uint8, jitter float64, cap time.Duration) *Backo { - return &Backo{base, factor, jitter, cap} -} - -// Creates a backo instance with the following defaults: -// base: 100 milliseconds -// factor: 2 -// jitter: 0 -// cap: 10 seconds -func DefaultBacko() *Backo { - return NewBacko(time.Millisecond*100, 2, 0, time.Second*10) -} - -// Duration returns the backoff interval for the given attempt. -func (backo *Backo) Duration(attempt int) time.Duration { - duration := float64(backo.base) * math.Pow(float64(backo.factor), float64(attempt)) - - if backo.jitter != 0 { - random := rand.Float64() - deviation := math.Floor(random * backo.jitter * duration) - if (int(math.Floor(random*10)) & 1) == 0 { - duration = duration - deviation - } else { - duration = duration + deviation - } - } - - duration = math.Min(float64(duration), float64(backo.cap)) - return time.Duration(duration) -} - -// Sleep pauses the current goroutine for the backoff interval for the given attempt. -func (backo *Backo) Sleep(attempt int) { - duration := backo.Duration(attempt) - time.Sleep(duration) -} - -type Ticker struct { - done chan struct{} - C <-chan time.Time -} - -func (b *Backo) NewTicker() *Ticker { - c := make(chan time.Time, 1) - ticker := &Ticker{ - done: make(chan struct{}, 1), - C: c, - } - - go func() { - for i := 0; ; i++ { - select { - case t := <-time.After(b.Duration(i)): - c <- t - case <-ticker.done: - close(c) - return - } - } - }() - - return ticker -} - -func (t *Ticker) Stop() { - t.done <- struct{}{} -} diff --git a/vendor/github.com/xtgo/uuid/AUTHORS b/vendor/github.com/xtgo/uuid/AUTHORS deleted file mode 100644 index a6f0451..0000000 --- a/vendor/github.com/xtgo/uuid/AUTHORS +++ /dev/null @@ -1,5 +0,0 @@ -# This source file refers to The gocql Authors for copyright purposes. - -Christoph Hack -Jonathan Rudenberg -Thorsten von Eicken diff --git a/vendor/github.com/xtgo/uuid/LICENSE b/vendor/github.com/xtgo/uuid/LICENSE deleted file mode 100644 index 18d25f9..0000000 --- a/vendor/github.com/xtgo/uuid/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2012 The gocql Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/xtgo/uuid/uuid.go b/vendor/github.com/xtgo/uuid/uuid.go deleted file mode 100644 index a0fd7a5..0000000 --- a/vendor/github.com/xtgo/uuid/uuid.go +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) 2012 The gocql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package uuid can be used to generate and parse universally unique -// identifiers, a standardized format in the form of a 128 bit number. -// -// http://tools.ietf.org/html/rfc4122 -package uuid - -import ( - "crypto/rand" - "encoding/hex" - "errors" - "io" - "net" - "strconv" - "time" -) - -type UUID [16]byte - -var hardwareAddr []byte - -const ( - VariantNCSCompat = 0 - VariantIETF = 2 - VariantMicrosoft = 6 - VariantFuture = 7 -) - -func init() { - if interfaces, err := net.Interfaces(); err == nil { - for _, i := range interfaces { - if i.Flags&net.FlagLoopback == 0 && len(i.HardwareAddr) > 0 { - hardwareAddr = i.HardwareAddr - break - } - } - } - if hardwareAddr == nil { - // If we failed to obtain the MAC address of the current computer, - // we will use a randomly generated 6 byte sequence instead and set - // the multicast bit as recommended in RFC 4122. - hardwareAddr = make([]byte, 6) - _, err := io.ReadFull(rand.Reader, hardwareAddr) - if err != nil { - panic(err) - } - hardwareAddr[0] = hardwareAddr[0] | 0x01 - } -} - -// Parse parses a 32 digit hexadecimal number (that might contain hyphens) -// representing an UUID. -func Parse(input string) (UUID, error) { - var u UUID - j := 0 - for i := 0; i < len(input); i++ { - b := input[i] - switch { - default: - fallthrough - case j == 32: - goto err - case b == '-': - continue - case '0' <= b && b <= '9': - b -= '0' - case 'a' <= b && b <= 'f': - b -= 'a' - 10 - case 'A' <= b && b <= 'F': - b -= 'A' - 10 - } - u[j/2] |= b << byte(^j&1<<2) - j++ - } - if j == 32 { - return u, nil - } -err: - return UUID{}, errors.New("invalid UUID " + strconv.Quote(input)) -} - -// FromBytes converts a raw byte slice to an UUID. It will panic if the slice -// isn't exactly 16 bytes long. -func FromBytes(input []byte) UUID { - var u UUID - if len(input) != 16 { - panic("UUIDs must be exactly 16 bytes long") - } - copy(u[:], input) - return u -} - -// NewRandom generates a totally random UUID (version 4) as described in -// RFC 4122. -func NewRandom() UUID { - var u UUID - io.ReadFull(rand.Reader, u[:]) - u[6] &= 0x0F // clear version - u[6] |= 0x40 // set version to 4 (random uuid) - u[8] &= 0x3F // clear variant - u[8] |= 0x80 // set to IETF variant - return u -} - -var timeBase = time.Date(1582, time.October, 15, 0, 0, 0, 0, time.UTC).Unix() - -// NewTime generates a new time based UUID (version 1) as described in RFC -// 4122. This UUID contains the MAC address of the node that generated the -// UUID, a timestamp and a sequence number. -func NewTime() UUID { - var u UUID - - now := time.Now().In(time.UTC) - t := uint64(now.Unix()-timeBase)*10000000 + uint64(now.Nanosecond()/100) - u[0], u[1], u[2], u[3] = byte(t>>24), byte(t>>16), byte(t>>8), byte(t) - u[4], u[5] = byte(t>>40), byte(t>>32) - u[6], u[7] = byte(t>>56)&0x0F, byte(t>>48) - - var clockSeq [2]byte - io.ReadFull(rand.Reader, clockSeq[:]) - u[8] = clockSeq[1] - u[9] = clockSeq[0] - - copy(u[10:], hardwareAddr) - - u[6] |= 0x10 // set version to 1 (time based uuid) - u[8] &= 0x3F // clear variant - u[8] |= 0x80 // set to IETF variant - - return u -} - -// String returns the UUID in it's canonical form, a 32 digit hexadecimal -// number in the form of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. -func (u UUID) String() string { - buf := [36]byte{8: '-', 13: '-', 18: '-', 23: '-'} - hex.Encode(buf[0:], u[0:4]) - hex.Encode(buf[9:], u[4:6]) - hex.Encode(buf[14:], u[6:8]) - hex.Encode(buf[19:], u[8:10]) - hex.Encode(buf[24:], u[10:]) - return string(buf[:]) -} - -// Bytes returns the raw byte slice for this UUID. A UUID is always 128 bits -// (16 bytes) long. -func (u UUID) Bytes() []byte { - return u[:] -} - -// Variant returns the variant of this UUID. This package will only generate -// UUIDs in the IETF variant. -func (u UUID) Variant() int { - x := u[8] - switch byte(0) { - case x & 0x80: - return VariantNCSCompat - case x & 0x40: - return VariantIETF - case x & 0x20: - return VariantMicrosoft - } - return VariantFuture -} - -// Version extracts the version of this UUID variant. The RFC 4122 describes -// five kinds of UUIDs. -func (u UUID) Version() int { - return int(u[6] & 0xF0 >> 4) -} - -// Node extracts the MAC address of the node who generated this UUID. It will -// return nil if the UUID is not a time based UUID (version 1). -func (u UUID) Node() []byte { - if u.Version() != 1 { - return nil - } - return u[10:] -} - -// Timestamp extracts the timestamp information from a time based UUID -// (version 1). -func (u UUID) Timestamp() uint64 { - if u.Version() != 1 { - return 0 - } - return uint64(u[0])<<24 + uint64(u[1])<<16 + uint64(u[2])<<8 + - uint64(u[3]) + uint64(u[4])<<40 + uint64(u[5])<<32 + - uint64(u[7])<<48 + uint64(u[6]&0x0F)<<56 -} - -// Time is like Timestamp, except that it returns a time.Time. -func (u UUID) Time() time.Time { - t := u.Timestamp() - if t == 0 { - return time.Time{} - } - sec := t / 10000000 - nsec := t - sec - return time.Unix(int64(sec)+timeBase, int64(nsec)) -} From 7a20670942bd8a27f6b34f7ae53fcbffa6232204 Mon Sep 17 00:00:00 2001 From: Hunter Blanks Date: Mon, 6 Jul 2020 12:20:59 -0700 Subject: [PATCH 2/2] circleci, Readme: fix circle build & point to it * Fix the v3.0 circle CI build; we had a duplicate jobs block and that was breaking it. * Update Readme.md on this branch so it points to this branch's build status. * Advance versions of go that we build for to the most recent 4 versions. --- .circleci/config.yml | 23 +++++++++-------------- Readme.md | 2 +- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6e17ae2..74295ca 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,23 +8,23 @@ jobs: steps: - checkout - run: make ci - build-go110: + build-go113: docker: - - image: circleci/golang:1.10 + - image: circleci/golang:1.13 working_directory: /go/src/github.com/segmentio/analytics-go steps: - checkout - run: make ci - build-go19: + build-go112: docker: - - image: circleci/golang:1.9 + - image: circleci/golang:1.12 working_directory: /go/src/github.com/segmentio/analytics-go steps: - checkout - run: make ci - build-go18: + build-go111: docker: - - image: circleci/golang:1.8 + - image: circleci/golang:1.11 working_directory: /go/src/github.com/segmentio/analytics-go steps: - checkout @@ -35,11 +35,6 @@ workflows: build: jobs: - build-golatest - - build-go110 - - build-go19 - - build-go18 - jobs: - - build-golatest - - build-go110 - - build-go19 - - build-go18 + - build-go113 + - build-go112 + - build-go111 diff --git a/Readme.md b/Readme.md index 7d369c1..5d3d822 100644 --- a/Readme.md +++ b/Readme.md @@ -1,4 +1,4 @@ -# analytics-go [![Circle CI](https://circleci.com/gh/segmentio/analytics-go/tree/master.svg?style=shield)](https://circleci.com/gh/segmentio/analytics-go/tree/master) [![go-doc](https://godoc.org/github.com/segmentio/analytics-go?status.svg)](https://godoc.org/github.com/segmentio/analytics-go) +# analytics-go [![Circle CI](https://circleci.com/gh/segmentio/analytics-go/tree/v3.0.svg?style=shield)](https://circleci.com/gh/segmentio/analytics-go/tree/v3.0) [![go-doc](https://godoc.org/github.com/segmentio/analytics-go?status.svg)](https://godoc.org/github.com/segmentio/analytics-go) Segment analytics client for Go.