From f5125e8874984b08e6137630bb9453c80241815f Mon Sep 17 00:00:00 2001 From: Format_C_eft Date: Thu, 2 Oct 2025 23:46:54 +0500 Subject: [PATCH] Update go version to 1.25 and update golang-lint version 2.5.0 --- .golangci.yml | 108 +++++++++++++++++++++++++++----------------- Makefile | 5 +- go.mod | 2 +- internal/cmd/dto.go | 1 + internal/cmd/run.go | 9 +++- 5 files changed, 78 insertions(+), 47 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index d07b37c..988991e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,55 +1,81 @@ -# More info on config here: https://golangci-lint.run/usage/configuration/#config-file +version: "2" run: concurrency: 8 - timeout: 10m issues-exit-code: 1 tests: true - -output: - formats: - - format: colored-line-number - print-issued-lines: true - print-linter-name: true - -linters-settings: - govet: - enable: - - shadow - dupl: - threshold: 100 - goconst: - min-len: 2 - min-occurrences: 2 - linters: - disable-all: true + default: none enable: + - dupl + - durationcheck + - errorlint - errcheck - goconst - - goimports - gosec - - gosimple - govet - ineffassign - revive - staticcheck - unused - -issues: - exclude-dirs: - - bin - - vendor - - var - - tmp - - .cache - exclude-use-default: false - exclude: - - G104 - - G115 - - G204 - - should have a package comment - - should have comment or be unexported - - comment on exported const - - should have comment \(or a comment on this block\) - - don't use an underscore in package name - - package-comments + - wsl_v5 + settings: + dupl: + threshold: 100 + goconst: + min-len: 2 + min-occurrences: 2 + govet: + enable: + - shadow + wsl_v5: + enable: + - assign + - branch + - decl + - defer + - expr + - for + - go + - if + - inc-dec + - label + - range + - return + - select + - switch + - type-switch + - append + - assign-expr + - err + - leading-whitespace + - trailing-whitespace + exclusions: + generated: lax + rules: + - path: (.+)\.go$ + text: G104 + - path: (.+)\.go$ + text: G115 + - path: (.+)\.go$ + text: G204 + - path: (.+)\.go$ + text: should have a package comment + - path: (.+)\.go$ + text: should have comment or be unexported + - path: (.+)\.go$ + text: comment on exported const + - path: (.+)\.go$ + text: should have comment \(or a comment on this block\) + - path: (.+)\.go$ + text: don't use an underscore in package name + - path: (.+)\.go$ + text: package-comments + paths: + - bin + - vendor + - var + - tmp + - .cache + - third_party$ + - builtin$ + - examples$ diff --git a/Makefile b/Makefile index fff5f15..5ba8a23 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ CURDIR_ESCAPE:=$(subst $(space),\ ,$(CURDIR)) LOCAL_BIN:=$(CURDIR_ESCAPE)/bin LINT_BIN:=$(LOCAL_BIN)/golangci-lint -LINT_VERSION:=1.60.3 +LINT_VERSION:=2.5.0 ###### TEST ###### .PHONY: test @@ -23,13 +23,12 @@ test: install-lint: ifeq ($(wildcard $(LINT_BIN)),) $(info Installing golangci-lint v$(LINT_VERSION)) - GOBIN=$(LOCAL_BIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v$(LINT_VERSION) + GOBIN=$(LOCAL_BIN) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v$(LINT_VERSION) # Устанавливаем текущий путь для исполняемого файла линтера. else $(info Golangci-lint is already installed to $(LINT_VERSION)) endif - PHONY: lint lint: install-lint $(info Running lint against changed files...) diff --git a/go.mod b/go.mod index 6dceace..e7c575d 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/Format-C-eft/git-update -go 1.23 +go 1.25 diff --git a/internal/cmd/dto.go b/internal/cmd/dto.go index 26ccf77..3f6ce52 100644 --- a/internal/cmd/dto.go +++ b/internal/cmd/dto.go @@ -50,5 +50,6 @@ func (r *resultLog) String() string { ), ) } + return strings.Join(result, "\n") } diff --git a/internal/cmd/run.go b/internal/cmd/run.go index 65b4693..8ed9302 100644 --- a/internal/cmd/run.go +++ b/internal/cmd/run.go @@ -54,8 +54,10 @@ func Run() error { ctx, cancel := context.WithTimeout(context.Background(), execTimeout) defer cancel() - var countDone atomic.Int32 - var countAll = int32(len(listDir)) + var ( + countDone atomic.Int32 + countAll = int32(len(listDir)) + ) for { select { @@ -64,6 +66,7 @@ func Run() error { case logChan := <-ch: fmt.Println(logChan.String()) fmt.Println("--------------------------------------------------------------------") + if newValue := countDone.Add(1); newValue >= countAll { return nil } @@ -93,6 +96,7 @@ func processDir(dir string, ch chan resultLog) { defer func() { resultLogs.AddLog("stop processing", "") + ch <- resultLogs }() @@ -112,6 +116,7 @@ func processDir(dir string, ch chan resultLog) { resultLogs.AddLog("skipped: there are uncommitted changes", "") return } + result, err := shell_executor.Run(ctx, dir, "git", "reset", "--hard") if err != nil { resultLogs.AddLog("error: git reset --hard", err.Error())