-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: code cleanup and upgrade to go 1.24
- Loading branch information
1 parent
f288b6c
commit 2337d5c
Showing
40 changed files
with
622 additions
and
438 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,72 @@ | ||
# General | ||
SHELL := bash | ||
.SHELLFLAGS := -eu -o pipefail -c | ||
.DEFAULT_GOAL := help | ||
# Use default shell BASH. | ||
SHELL_PATH := /bin/bash | ||
SHELL := /usr/bin/env bash | ||
|
||
BIN := $(CURDIR)/.bin | ||
TOOLS := $(CURDIR)/tools | ||
PATH := $(abspath $(BIN)):$(PATH) | ||
# ============================================================================== | ||
# Define dependencies | ||
|
||
UNAME_OS := $(shell uname -s) | ||
UNAME_ARCH := $(shell uname -m) | ||
NAME := go-hubspot | ||
GOBIN := $$HOME/go/bin | ||
GOVULNCHECK := $(GOBIN)/govulncheck | ||
STATICCHECK := $(GOBIN)/staticcheck | ||
TOOLS := tools | ||
|
||
$(BIN): | ||
mkdir -p $(BIN) | ||
# ============================================================================== | ||
# Defining all make targets | ||
|
||
.PHONY: os | ||
os: ## show os name | ||
@echo "$(UNAME_OS)" | ||
.DEFAULT_GOAL := all | ||
|
||
.PHONY: help | ||
help: ## print help | ||
@grep -E '^[/a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' | ||
.PHONY: all | ||
all: update fmt lint vulncheck tidy test | ||
|
||
# Go | ||
.PHONY: fmt | ||
fmt: | ||
@echo "-- Formatting Go files --" | ||
gofmt -w -s . && \ | ||
gofmt -w -s legacy && \ | ||
goimports -local github.com/belong-inc/go-hubspot -w . | ||
|
||
.PHONY: mod | ||
mod: ## download Go modules | ||
go mod download | ||
.PHONY: generate | ||
generate: ## generate go code (e.g. make generate OBJECT=Contact FILEPATH=contact.csv) | ||
@cd $(TOOLS)/model_generator && go run model_gen.go $(OBJECT) $(FILEPATH) | ||
$(MAKE) fmt | ||
|
||
.PHONY: vendor | ||
vendor: ## make go vendor | ||
go mod vendor | ||
.PHONY: lint | ||
lint: | ||
@echo "-- Lint check for Go files --" | ||
go mod tidy | ||
golangci-lint run | ||
CGO_ENABLED=0 go vet ./... | ||
|
||
.PHONY: test | ||
test: ## run go test. If you need test options, pass them in like OPTIONS="-v" | ||
go test ./... $(OPTIONS) | ||
.PHONY: staticcheck | ||
staticcheck: | ||
$(STATICCHECK) -checks=all ./... | ||
|
||
# Install golangci-lint | ||
GOLANGCLI_LINT := $(BIN)/golangci-lint | ||
GOLANGCLI_LINT_VERSION := v1.51.0 | ||
$(GOLANGCLI_LINT): | $(BIN) ## Install golangci-lint | ||
@curl -sSfL "https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" | sh -s -- -b $(BIN) $(GOLANGCLI_LINT_VERSION) | ||
@chmod +x "$(BIN)/golangci-lint" | ||
.PHONY: vulncheck | ||
vulncheck: | ||
$(GOVULNCHECK) ./... | ||
|
||
.PHONY: lint | ||
lint: | $(GOLANGCLI_LINT) ## run golangci-lint with config .golangcli.yml | ||
$(BIN)/golangci-lint run --verbose --config=.golangci.yml ./... | ||
.PHONY: update | ||
update: | ||
go get -u ./... | ||
|
||
# Install gofumpt | ||
# This setting is only available for Mac | ||
GOFMPT := $(BIN)/gofumpt | ||
GOFMPT_VERSION := v0.4.0 | ||
ifeq "$(UNAME_OS)" "Darwin" | ||
GOFMPT_BIN=gofumpt_$(GOFMPT_VERSION)_darwin_amd64 | ||
endif | ||
.PHONY: tidy | ||
tidy: | ||
@echo "-- Tidying Go modules --" | ||
go mod tidy | ||
|
||
$(GOFMPT): | $(BIN) ## Install gofumpt | ||
@curl -sSfL "https://github.com/mvdan/gofumpt/releases/download/$(GOFMPT_VERSION)/$(GOFMPT_BIN)" \ | ||
-o "$(BIN)/gofumpt" | ||
@chmod +x "$(BIN)/gofumpt" | ||
.PHONY: clean | ||
clean: | ||
@echo " -- Cleaning Go files --" | ||
@go clean -cache -testcache -modcache | ||
@rm $(GO_DIR)/*.zip | ||
|
||
.PHONY: fmt | ||
fmt: | $(GOFMPT) ## format files via gofumpt and list impacted files | ||
@$(BIN)/gofumpt -l -w . ./legacy | ||
.PHONY: build | ||
build: | ||
@echo "-- Building binaries --" | ||
go build -v ./... | ||
|
||
.PHONY: generate | ||
generate: ## generate go code (e.g. make generate OBJECT=Contact FILEPATH=contact.csv) | ||
@cd $(TOOLS)/model_generator && go run model_gen.go $(OBJECT) $(FILEPATH) | ||
$(MAKE) fmt | ||
.PHONY: | ||
test: build | ||
@echo "-- Running tests --" | ||
CGO_ENABLED=1 go test ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
package hubspot | ||
|
||
const ( | ||
visitorIdentificationBasePath = "/conversations/v3/visitor-identification" | ||
visitorIDentificationBasePath = "/conversations/v3/visitor-identification" | ||
) | ||
|
||
type Conversation struct { | ||
VisitorIdentification VisitorIdentificationService | ||
VisitorIDentification VisitorIDentificationService | ||
} | ||
|
||
func newConversation(c *Client) *Conversation { | ||
return &Conversation{ | ||
VisitorIdentification: &VisitorIdentificationServiceOp{ | ||
VisitorIDentification: &VisitorIDentificationServiceOp{ | ||
client: c, | ||
basePath: visitorIdentificationBasePath, | ||
basePath: visitorIDentificationBasePath, | ||
}, | ||
} | ||
} |
Oops, something went wrong.