Switch to go modules & update linter config (#49)

* update linter action config & fix for tests
* removed deprecate linters from the config
* switch to go modules
This commit is contained in:
Pavel 2021-04-16 14:25:25 +03:00 committed by GitHub
parent d551e91985
commit 03fc70d679
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 21 deletions

View File

@ -27,22 +27,21 @@ jobs:
go-version: '^1' go-version: '^1'
- name: Get dependencies - name: Get dependencies
run: | run: |
go get -v github.com/google/go-querystring/query go mod tidy
go get -v github.com/h2non/gock
go get -v github.com/joho/godotenv
go get -v github.com/retailcrm/api-client-go/errs
cp .env.dist .env cp .env.dist .env
- name: Lint code with golangci-lint - name: Lint code with golangci-lint
uses: golangci/golangci-lint-action@v2 uses: golangci/golangci-lint-action@v2
with: with:
version: v1.36 version: v1.39
only-new-issues: true only-new-issues: true
skip-go-installation: true
skip-pkg-cache: true
tests: tests:
name: Tests name: Tests
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
go-version: ['1.8', '1.9', '1.10', '1.11', '1.12', '1.13'] go-version: ['1.11', '1.12', '1.13', '1.14', '1.15', '1.16']
include: include:
- go-version: '1.14' - go-version: '1.14'
coverage: 1 coverage: 1
@ -55,10 +54,7 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Get dependencies - name: Get dependencies
run: | run: |
go get -v github.com/google/go-querystring/query go mod tidy
go get -v github.com/h2non/gock
go get -v github.com/joho/godotenv
go get -v github.com/retailcrm/api-client-go/errs
cp .env.dist .env cp .env.dist .env
- name: Tests - name: Tests
env: env:

View File

@ -36,15 +36,12 @@ linters:
- gomnd - gomnd
- gosec - gosec
- ifshort - ifshort
- interfacer
- lll - lll
- makezero - makezero
- maligned
- misspell - misspell
- nestif - nestif
- prealloc - prealloc
- predeclared - predeclared
- scopelint
- sqlclosecheck - sqlclosecheck
- unconvert - unconvert
- whitespace - whitespace

9
go.mod Normal file
View File

@ -0,0 +1,9 @@
module github.com/retailcrm/api-client-go
go 1.13
require (
github.com/google/go-querystring v1.1.0
github.com/joho/godotenv v1.3.0
gopkg.in/h2non/gock.v1 v1.0.16
)

19
go.sum Normal file
View File

@ -0,0 +1,19 @@
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20191021144547-ec77196f6094/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
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/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/h2non/gentleman.v1 v1.0.4/go.mod h1:JYuHVdFzS4MKOXe0o+chKJ4hCe6tqKKw9XH9YP6WFrg=
gopkg.in/h2non/gock.v1 v1.0.16 h1:F11k+OafeuFENsjei5t2vMTSTs9L62AdyTe4E1cgdG8=
gopkg.in/h2non/gock.v1 v1.0.16/go.mod h1:XVuDAssexPLwgxCLMvDTWNU5eqklsydR6I5phZ9oPB8=

View File

@ -617,7 +617,7 @@ func (c *Client) CustomerNoteDelete(id int) (SuccessfulResponse, int, *errs.Fail
var resp SuccessfulResponse var resp SuccessfulResponse
p := url.Values{ p := url.Values{
"id": {string(id)}, "id": {strconv.Itoa(id)},
} }
data, status, err := c.PostRequest(fmt.Sprintf("/customers/notes/%d/delete", id), p) data, status, err := c.PostRequest(fmt.Sprintf("/customers/notes/%d/delete", id), p)
@ -1106,7 +1106,7 @@ func (c *Client) CorporateCustomerNoteDelete(id int) (SuccessfulResponse, int, *
var resp SuccessfulResponse var resp SuccessfulResponse
p := url.Values{ p := url.Values{
"id": {string(id)}, "id": {strconv.Itoa(id)},
} }
data, status, err := c.PostRequest(fmt.Sprintf("/customers-corporate/notes/%d/delete", id), p) data, status, err := c.PostRequest(fmt.Sprintf("/customers-corporate/notes/%d/delete", id), p)
@ -2437,7 +2437,7 @@ func (c *Client) OrderPaymentDelete(id int) (SuccessfulResponse, int, *errs.Fail
var resp SuccessfulResponse var resp SuccessfulResponse
p := url.Values{ p := url.Values{
"id": {string(id)}, "id": {strconv.Itoa(id)},
} }
data, status, err := c.PostRequest(fmt.Sprintf("/orders/payments/%d/delete", id), p) data, status, err := c.PostRequest(fmt.Sprintf("/orders/payments/%d/delete", id), p)

View File

@ -15,8 +15,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/h2non/gock"
"github.com/joho/godotenv" "github.com/joho/godotenv"
gock "gopkg.in/h2non/gock.v1"
) )
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
@ -1817,7 +1817,7 @@ func TestClient_NotesCreateDelete(t *testing.T) {
} }
p = url.Values{ p = url.Values{
"id": {string(1)}, "id": {"1"},
} }
gock.New(crmURL). gock.New(crmURL).
@ -1879,7 +1879,7 @@ func TestClient_NotesCreateDelete_Fail(t *testing.T) {
} }
p = url.Values{ p = url.Values{
"id": {string(iCodeFail)}, "id": {strconv.Itoa(iCodeFail)},
} }
gock.New(crmURL). gock.New(crmURL).
@ -2564,7 +2564,7 @@ func TestClient_PaymentCreateEditDelete(t *testing.T) {
} }
p = url.Values{ p = url.Values{
"id": {string(paymentCreateResponse.ID)}, "id": {strconv.Itoa(paymentCreateResponse.ID)},
} }
gock.New(crmURL). gock.New(crmURL).
@ -2655,7 +2655,7 @@ func TestClient_PaymentCreateEditDelete_Fail(t *testing.T) {
} }
p = url.Values{ p = url.Values{
"id": {string(iCodeFail)}, "id": {strconv.Itoa(iCodeFail)},
} }
gock.New(crmURL). gock.New(crmURL).