From 83769fd2ec88f699c1163115d009bb9846b13b31 Mon Sep 17 00:00:00 2001 From: kk-no Date: Wed, 15 Mar 2023 17:35:56 +0900 Subject: [PATCH 1/2] upgrade go and toolset version and run formatter --- .github/workflows/test.yml | 2 +- Makefile | 4 ++-- crm_imports_start.go | 8 ++++++-- crm_imports_test.go | 5 ++--- doc.go | 1 - go.mod | 2 +- legacy/doc.go | 1 - 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aeb9cf9..0a0aef7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: - name: setup uses: actions/setup-go@v2 with: - go-version: "1.14" + go-version: "1.16" - name: lint run: make lint - name: test diff --git a/Makefile b/Makefile index ce4b159..042742f 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ test: ## run go test # Install golangci-lint GOLANGCLI_LINT := $(BIN)/golangci-lint -GOLANGCLI_LINT_VERSION := v1.43.0 +GOLANGCLI_LINT_VERSION := v1.51.0 $(GOLANGCLI_LINT): | $(BIN) ## Install golangci-lint @curl -sSfL "https://github.com/raw/golangci/golangci-lint/master/install.sh" | sh -s -- -b $(BIN) $(GOLANGCLI_LINT_VERSION) @chmod +x "$(BIN)/golangci-lint" @@ -44,7 +44,7 @@ lint: | $(GOLANGCLI_LINT) ## run golangci-lint with config .golangcli.yml # Install gofumpt # This setting is only available for Mac GOFMPT := $(BIN)/gofumpt -GOFMPT_VERSION := v0.1.0 +GOFMPT_VERSION := v0.4.0 ifeq "$(UNAME_OS)" "Darwin" GOFMPT_BIN=gofumpt_$(GOFMPT_VERSION)_darwin_amd64 endif diff --git a/crm_imports_start.go b/crm_imports_start.go index f4e3315..e8601c2 100644 --- a/crm_imports_start.go +++ b/crm_imports_start.go @@ -47,7 +47,9 @@ func addJSONtoMultipart(writer *multipart.Writer, importRequest *CrmImportConfig if err != nil { return err } - part.Write([]byte(data)) + if _, err := part.Write(data); err != nil { + return err + } return nil } @@ -63,7 +65,9 @@ func addFilesToMultipart(writer *multipart.Writer, importRequest *CrmImportConfi if err != nil { return err } - csvPart.Write(fileData) + if _, err := csvPart.Write(fileData); err != nil { + return err + } } return nil } diff --git a/crm_imports_test.go b/crm_imports_test.go index 5e21a18..eaaa718 100644 --- a/crm_imports_test.go +++ b/crm_imports_test.go @@ -47,13 +47,13 @@ func createTestCsv(count int) *bytes.Buffer { buf := &bytes.Buffer{} csvwriter := csv.NewWriter(buf) csvHeader := []string{"email", "firstname", "lastname"} - csvwriter.Write(csvHeader) + _ = csvwriter.Write(csvHeader) for i := 0; i < count; i++ { testFirst := fmt.Sprintf("FirstName3%d", i) testLast := fmt.Sprintf("LastName%d", i) testEmail := fmt.Sprintf("test%d@example.com", i) - csvwriter.Write([]string{testEmail, testFirst, testLast}) + _ = csvwriter.Write([]string{testEmail, testFirst, testLast}) } csvwriter.Flush() return buf @@ -104,5 +104,4 @@ func TestImportStart(t *testing.T) { fmt.Printf("%+v\n", res) fmt.Printf("%+v\n", err) // t.Error(1) - } diff --git a/doc.go b/doc.go index fc1d209..1152634 100644 --- a/doc.go +++ b/doc.go @@ -17,6 +17,5 @@ Package hubspot is the root of packages used to access Hubspot APIs. This library is targeting HubSpot API v3. Docs are available in https://developers.hubspot.com/docs/api/overview. - */ package hubspot diff --git a/go.mod b/go.mod index ff8812f..7ed754d 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/belong-inc/go-hubspot -go 1.14 +go 1.16 require ( github.com/google/go-cmp v0.5.4 diff --git a/legacy/doc.go b/legacy/doc.go index 687419f..0399983 100644 --- a/legacy/doc.go +++ b/legacy/doc.go @@ -17,6 +17,5 @@ Package legacy is the package for legacy APIs in Hubspot. Not all APIs of Hubspot have been migrated v3 therefore components for legacy API is put in this package. Docs are available in https://legacydocs.hubspot.com/docs/overview. - */ package legacy From 42b7f5ded374e518399e47ac2d361768bccdc004 Mon Sep 17 00:00:00 2001 From: kk-no Date: Wed, 15 Mar 2023 18:00:46 +0900 Subject: [PATCH 2/2] add ci job trigger --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0a0aef7..e3c532a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,8 @@ name: lint and test -on: push +on: + push: + pull_request: jobs: test: