From 2819894c01ef035b6225aa19eafcb2168f61a1a6 Mon Sep 17 00:00:00 2001 From: Stephen Young Date: Wed, 16 Jun 2021 09:46:43 -0400 Subject: [PATCH 1/7] modfile, split out _test package --- go.mod | 3 +++ options.go | 16 ++++++++-------- options_test.go | 32 +++++++++++++++++--------------- 3 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 go.mod diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..4dce4b4 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/customerio/go-customerio + +go 1.16 diff --git a/options.go b/options.go index 28ae1ef..ffe9c55 100644 --- a/options.go +++ b/options.go @@ -8,28 +8,28 @@ type option struct { } type region struct { - apiURL string - trackURL string + ApiURL string + TrackURL string } var ( RegionUS = region{ - apiURL: "https://api.customer.io", - trackURL: "https://track.customer.io", + ApiURL: "https://api.customer.io", + TrackURL: "https://track.customer.io", } RegionEU = region{ - apiURL: "https://api-eu.customer.io", - trackURL: "https://track-eu.customer.io", + ApiURL: "https://api-eu.customer.io", + TrackURL: "https://track-eu.customer.io", } ) func WithRegion(r region) option { return option{ api: func(a *APIClient) { - a.URL = r.apiURL + a.URL = r.ApiURL }, track: func(c *CustomerIO) { - c.URL = r.trackURL + c.URL = r.TrackURL }, } } diff --git a/options_test.go b/options_test.go index 2f6389f..c25f255 100644 --- a/options_test.go +++ b/options_test.go @@ -1,25 +1,27 @@ -package customerio +package customerio_test import ( "net/http" "reflect" "testing" + + "github.com/customerio/go-customerio" ) func TestAPIOptions(t *testing.T) { - client := NewAPIClient("mykey") - if client.URL != RegionUS.apiURL { - t.Errorf("wrong default url. got: %s, want: %s", client.URL, RegionUS.apiURL) + client := customerio.NewAPIClient("mykey") + if client.URL != customerio.RegionUS.ApiURL { + t.Errorf("wrong default url. got: %s, want: %s", client.URL, customerio.RegionUS.ApiURL) } - client = NewAPIClient("mykey", WithRegion(RegionEU)) - if client.URL != RegionEU.apiURL { - t.Errorf("wrong url. got: %s, want: %s", client.URL, RegionEU.apiURL) + client = customerio.NewAPIClient("mykey", customerio.WithRegion(customerio.RegionEU)) + if client.URL != customerio.RegionEU.ApiURL { + t.Errorf("wrong url. got: %s, want: %s", client.URL, customerio.RegionEU.ApiURL) } hc := &http.Client{} - client = NewAPIClient("mykey", WithHTTPClient(hc)) + client = customerio.NewAPIClient("mykey", customerio.WithHTTPClient(hc)) if !reflect.DeepEqual(client.Client, hc) { t.Errorf("wrong http client. got: %#v, want: %#v", client.Client, hc) } @@ -27,18 +29,18 @@ func TestAPIOptions(t *testing.T) { func TestTrackOptions(t *testing.T) { - client := NewTrackClient("site_id", "api_key") - if client.URL != RegionUS.trackURL { - t.Errorf("wrong default url. got: %s, want: %s", client.URL, RegionUS.trackURL) + client := customerio.NewTrackClient("site_id", "api_key") + if client.URL != customerio.RegionUS.TrackURL { + t.Errorf("wrong default url. got: %s, want: %s", client.URL, customerio.RegionUS.TrackURL) } - client = NewTrackClient("site_id", "api_key", WithRegion(RegionEU)) - if client.URL != RegionEU.trackURL { - t.Errorf("wrong url. got: %s, want: %s", client.URL, RegionEU.trackURL) + client = customerio.NewTrackClient("site_id", "api_key", customerio.WithRegion(customerio.RegionEU)) + if client.URL != customerio.RegionEU.TrackURL { + t.Errorf("wrong url. got: %s, want: %s", client.URL, customerio.RegionEU.TrackURL) } hc := &http.Client{} - client = NewTrackClient("site_id", "api_key", WithHTTPClient(hc)) + client = customerio.NewTrackClient("site_id", "api_key", customerio.WithHTTPClient(hc)) if !reflect.DeepEqual(client.Client, hc) { t.Errorf("wrong http client. got: %#v, want: %#v", client.Client, hc) } From 69424461a17d7b9a3cce12d0ac681c273dab3d12 Mon Sep 17 00:00:00 2001 From: Stephen Young Date: Wed, 16 Jun 2021 09:49:31 -0400 Subject: [PATCH 2/7] modules and cleanups --- .github/workflows/main.yml | 2 +- CHANGELOG.md | 11 +++++++++-- LICENSE | 2 +- README.md | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9f5c308..14e41b6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: [ '1.10', '1.11', '1.12' ] + go: [ '1.15', '1.16' ] env: TEST_RESULTS: /tmp/test-results name: Go ${{ matrix.go }} test diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eae3bb..66c8a2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ # Changelog -## March 24, 2021 +## June 16, 2021 v2.2.0 + +### Added +- Modules support +- Updated license date +- Upgraded version support + +## March 24, 2021 v2.1.0 ### Added - Support for EU region - Allow using custom `*http.Client` @@ -8,7 +15,7 @@ ### Changed - `customerio.NewAPIClient` and `customerio.NewTrackClient` have a new variadic parameter for options in order to choose US/EU region and/or customer HTTP client. -## December 3, 2020 +## December 3, 2020 v2.0.0 ### Added - Support for transactional api diff --git a/LICENSE b/LICENSE index 793dd2e..4ce7328 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 Customer IO +Copyright (c) 2021 Customer IO Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 199f202..106a646 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ # go-customerio [![CircleCI](https://circleci.com/gh/customerio/go-customerio/tree/master.svg?style=svg)](https://circleci.com/gh/customerio/go-customerio/tree/master) A golang client for the [Customer.io](http://customer.io) [event API](https://app.customer.io/api/docs/index.html). -_Tested with Go1.12_ +_Tested with Go1.16_ Godoc here: [https://godoc.org/github.com/customerio/go-customerio](https://godoc.org/github.com/customerio/go-customerio) From dd36ded3143f5504bb7693de9b602f84149794da Mon Sep 17 00:00:00 2001 From: Stephen Young Date: Wed, 16 Jun 2021 10:00:06 -0400 Subject: [PATCH 3/7] we're at v2 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 4dce4b4..ab8c162 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/customerio/go-customerio +module github.com/customerio/go-customerio/v2 go 1.16 From 525b0c8369cc98383d72e1becdb64507d89fe8be Mon Sep 17 00:00:00 2001 From: Stephen Young Date: Wed, 16 Jun 2021 10:01:30 -0400 Subject: [PATCH 4/7] no gopath --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 14e41b6..2dea6bf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,5 +25,4 @@ jobs: run: | curl -sSL "https://github.com/gotestyourself/gotestsum/releases/download/v0.6.0/gotestsum_0.6.0_linux_amd64.tar.gz" | sudo tar -xz -C /usr/local/bin gotestsum - run: | - export GOPATH="${GOPATH}:${GITHUB_WORKSPACE}" gotestsum --junitfile ${TEST_RESULTS}/unit-tests.xml -- -timeout 5m -p 1 ./... From aa6538d2fb5e0cfc14827a607526b4792cc41c63 Mon Sep 17 00:00:00 2001 From: Stephen Young Date: Wed, 16 Jun 2021 10:03:18 -0400 Subject: [PATCH 5/7] /v2 --- README.md | 4 ++-- customerio_test.go | 2 +- examples/transactional.go | 2 +- options_test.go | 2 +- send_email_test.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 106a646..fe4885e 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Add this line to your application's imports: ```go import ( // ... - "github.com/customerio/go-customerio" + "github.com/customerio/go-customerio/v2" ) ``` @@ -24,7 +24,7 @@ And then execute: Or install it yourself: - $ go get "github.com/customerio/go-customerio" + $ go get github.com/customerio/go-customerio ## Usage diff --git a/customerio_test.go b/customerio_test.go index 759a233..88a4c7c 100644 --- a/customerio_test.go +++ b/customerio_test.go @@ -13,7 +13,7 @@ import ( "strings" "testing" - "github.com/customerio/go-customerio" + "github.com/customerio/go-customerio/v2" ) var cio *customerio.CustomerIO diff --git a/examples/transactional.go b/examples/transactional.go index 10f561b..2172b46 100644 --- a/examples/transactional.go +++ b/examples/transactional.go @@ -5,7 +5,7 @@ import ( "fmt" "os" - "github.com/customerio/go-customerio" + "github.com/customerio/go-customerio/v2" ) func main() { diff --git a/options_test.go b/options_test.go index c25f255..a3d353f 100644 --- a/options_test.go +++ b/options_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "github.com/customerio/go-customerio" + "github.com/customerio/go-customerio/v2" ) func TestAPIOptions(t *testing.T) { diff --git a/send_email_test.go b/send_email_test.go index 66800d8..770afa0 100644 --- a/send_email_test.go +++ b/send_email_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/customerio/go-customerio" + "github.com/customerio/go-customerio/v2" ) func TestSendEmail(t *testing.T) { From 9af89d098037348c36c6769efba58f14203585c0 Mon Sep 17 00:00:00 2001 From: Stephen Young Date: Wed, 16 Jun 2021 10:10:10 -0400 Subject: [PATCH 6/7] checkout normal --- .github/workflows/main.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2dea6bf..8594027 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,14 +7,12 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: [ '1.15', '1.16' ] + go: [ '1.15', '1.16.4' ] env: TEST_RESULTS: /tmp/test-results name: Go ${{ matrix.go }} test steps: - uses: actions/checkout@v2 - with: - path: src/github.com/customerio/go-customerio - name: setup go uses: actions/setup-go@v2 with: From 5163d03e3b2a76448ea8a731fc430af5bfd68911 Mon Sep 17 00:00:00 2001 From: Stephen Young Date: Wed, 16 Jun 2021 17:31:31 -0400 Subject: [PATCH 7/7] 1.16 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8594027..9194f0c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: [ '1.15', '1.16.4' ] + go: [ '1.15', '1.16' ] env: TEST_RESULTS: /tmp/test-results name: Go ${{ matrix.go }} test