From a293d8f373fd0a15ad7f06a3ac6d27dd1be0754b Mon Sep 17 00:00:00 2001 From: Format_C_eft Date: Mon, 15 Jan 2024 18:46:59 +0500 Subject: [PATCH] upgrade libss --- .gitattributes | 3 +- .github/workflows/build.yml | 2 +- .github/workflows/lint.yml | 6 +-- .github/workflows/tests.yml | 4 +- .gitignore | 9 ++-- Makefile | 50 ++++++++++++++--------- go.mod | 9 ++-- go.sum | 12 +++--- internal/cmd/run.go | 6 +-- internal/shell_executor/shell_executor.go | 4 +- 10 files changed, 54 insertions(+), 51 deletions(-) diff --git a/.gitattributes b/.gitattributes index e16bf9b..31f00d0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ -go.sum -diff +*.sum -diff +*_gen.go -diff \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 40e14e1..c6297d4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.19.x + go-version: 1.21.x - name: Build shell: bash diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 20bdecd..2b827dd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,8 +11,8 @@ on: - master jobs: - lint: # golangci: - name: lint + lint: + name: lint-full runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -20,7 +20,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.19.x + go-version: 1.21.x - name: golangci-lint uses: golangci/golangci-lint-action@v3 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1b68817..28d0ccd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: test: strategy: matrix: - go-version: [1.17.x] + go-version: [1.21.x] os: [ubuntu-latest] runs-on: ubuntu-latest steps: @@ -23,7 +23,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.19.x + go-version: 1.21.x - name: Test shell: bash diff --git a/.gitignore b/.gitignore index 7a433ea..fd15355 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,5 @@ +/bin +.DS_STORE /.idea /.vscode -/.run -.DS_STORE -.DS_Store - -/bin -coverage.out \ No newline at end of file +/.run \ No newline at end of file diff --git a/Makefile b/Makefile index 47de55c..5ad5b29 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,41 @@ export GO111MODULE=on -export GOSUMDB=off -LOCAL_BIN = $(CURDIR)/bin -GOBIN = $(GOPATH)/bin -GOARCH = amd64 +ENV_PARAMS ?= CGO_ENABLED=0 +LOCAL_BIN := $(CURDIR)/bin +LINT_BIN := $(LOCAL_BIN)/golangci-lint -.PHONY: bin-deps -bin-deps: - $(info Installing binary dependencies...) - GOBIN=$(LOCAL_BIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1 +.PHONY: deps +deps: + $(info Download dependencies...) + go mod download + +.PHONY: test +test: + $(info Running test...) + go test ./... .PHONY: .lint .lint: - $(LOCAL_BIN)/golangci-lint run --config=.golangci.yaml ./... + $(info Running lint...) + $(LINT_BIN) run --new-from-rev=origin/master --config=.golangci.yaml ./... + +.PHONY: .lint-full +.lint-full: + $(info Running lint-full...) + $(LINT_BIN) run --config=.golangci.yaml ./... + +.PHONY: lint +lint: install-lint .lint -.PHONY: lint -lint: bin-deps .lint +.PHONY: lint-full +lint-full: install-lint .lint-full + +LINT_TAG ?= 1.55.2 +install-lint: export GOBIN := $(LOCAL_BIN) +install-lint: + $(info Installing golangci-lint v$(LINT_TAG)) + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v$(LINT_TAG) + go mod tidy .PHONY: build build: build-linux build-darwin @@ -29,11 +49,3 @@ build-linux: build-darwin: go mod download && CGO_ENABLED=0 \ GOOS=darwin GOARCH=${GOARCH} go build -o ${LOCAL_BIN}/git-update-darwin-${GOARCH} ./cmd/main.go; - -.PHONY: test -test: - go test ./... -count=1 -timeout=60s -v -short - -.PHONY: install -install: - go build -o $(GOBIN)/protogen -ldflags "$(LDFLAGS)" $(CURDIR)/cmd \ No newline at end of file diff --git a/go.mod b/go.mod index 8ef7cab..7d620de 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,10 @@ module github.com/Format-C-eft/git-update -go 1.19 +go 1.21 -require ( - github.com/pkg/errors v0.9.1 - github.com/spf13/cobra v1.6.1 -) +require github.com/spf13/cobra v1.8.0 require ( - github.com/inconshreveable/mousetrap v1.0.1 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect ) diff --git a/go.sum b/go.sum index 47e64c4..d0e8c2c 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,9 @@ -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= -github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= -github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= +github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/cmd/run.go b/internal/cmd/run.go index 04f46d6..eb07172 100644 --- a/internal/cmd/run.go +++ b/internal/cmd/run.go @@ -2,12 +2,12 @@ package cmd import ( "context" + "errors" "fmt" "os" "strings" "sync" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/Format-C-eft/git-update/internal/shell_executor" @@ -34,7 +34,7 @@ func cmdRun(_ *cobra.Command, _ []string) error { listDir, err := getListOfDirectories() if err != nil { - return errors.Wrap(err, "getListOfDirectories") + return fmt.Errorf("getListOfDirectories err: %w", err) } if len(listDir) == 0 { @@ -55,7 +55,7 @@ func cmdRun(_ *cobra.Command, _ []string) error { func getListOfDirectories() ([]string, error) { list, err := os.ReadDir(flagDir) if err != nil { - return nil, errors.Wrap(err, "os.ReadDir") + return nil, fmt.Errorf("os.ReadDir err: %w", err) } listDir := make([]string, 0, len(list)) diff --git a/internal/shell_executor/shell_executor.go b/internal/shell_executor/shell_executor.go index 87c7dfc..1f60ba0 100644 --- a/internal/shell_executor/shell_executor.go +++ b/internal/shell_executor/shell_executor.go @@ -5,8 +5,6 @@ import ( "context" "fmt" "os/exec" - - "github.com/pkg/errors" ) func Run(ctx context.Context, dir string, cmdline ...string) ([]byte, error) { @@ -20,7 +18,7 @@ func Run(ctx context.Context, dir string, cmdline ...string) ([]byte, error) { err := cmd.Run() if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("%s in %s error: %s", cmdline, dir, stderr.String())) + return nil, fmt.Errorf("%s in %s cmd_error: %s err: %w", cmdline, dir, stderr.String(), err) } return stdout.Bytes(), nil