-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add semaphore like in errgroup and return wrapped errors * Add new tests for stable version * Update go version and remove all deps * Add Makefile to run fmt, linter and tests * Add Gitub CI * Add comments for new functions * Rename module to an idiomatic name * Update README * Update README and LICENSE
- Loading branch information
Showing
12 changed files
with
895 additions
and
161 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.22' # Задайте нужную версию Go | ||
|
||
- name: Run make command | ||
run: make ci |
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 +1,4 @@ | ||
.idea | ||
bin | ||
|
||
coverage.* |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
BIN_DIR = $(PWD)/bin | ||
|
||
GOIMPORTS_BIN = $(BIN_DIR)/goimports | ||
GOLANGCI_BIN = $(BIN_DIR)/golangci-lint | ||
|
||
.PHONY: all | ||
all: tidy fmt lint test | ||
|
||
.PHONY: tidy | ||
tidy: | ||
go mod tidy | ||
|
||
.PHONY: test | ||
test: | ||
go test -v -race -cover -coverprofile=coverage.out -timeout 10s -cpu 1,2,4,8 ./... | ||
go tool cover -html=coverage.out -o coverage.html | ||
|
||
.PHONY: vet | ||
vet: | ||
go vet ./... | ||
|
||
.PHONY: fmt | ||
fmt: | ||
go fmt ./... | ||
$(GOIMPORTS_BIN) -w . | ||
|
||
.PHONY: lint | ||
lint: vet | ||
$(GOLANGCI_BIN) run -c golangci.yaml ./... | ||
|
||
.PHONY: ci | ||
ci: deps lint test | ||
|
||
.PHONY: deps | ||
deps: | ||
go mod download | ||
mkdir -p $(BIN_DIR) | ||
GOBIN=$(BIN_DIR) go install golang.org/x/tools/cmd/goimports@v0.26.0 | ||
GOBIN=$(BIN_DIR) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0 |
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,8 +1,5 @@ | ||
module github.com/Kurt212/syncgroup | ||
module github.com/kurt212/syncgroup | ||
|
||
go 1.13 | ||
go 1.22.1 | ||
|
||
require ( | ||
github.com/pkg/errors v0.9.1 | ||
github.com/stretchr/testify v1.5.1 | ||
) | ||
toolchain go1.22.5 |
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,15 +0,0 @@ | ||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= | ||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= | ||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= | ||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= | ||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= | ||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
linters: | ||
enable-all: true | ||
disable: | ||
- depguard | ||
- exportloopref | ||
- gomnd | ||
- execinquery |
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package testutil | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
// Equal is a helper function to check equality of two values. | ||
func Equal(t *testing.T, expected, actual any, optionalMessage ...string) { | ||
t.Helper() | ||
|
||
var message string | ||
if len(optionalMessage) > 0 { | ||
message = optionalMessage[0] | ||
} | ||
|
||
if !reflect.DeepEqual(expected, actual) { | ||
t.Fatalf("expected %v, got %v %q", expected, actual, message) | ||
} | ||
} | ||
|
||
// True is Helper function to check if a value is true. | ||
func True(t *testing.T, actual bool, optionalMessage ...string) { | ||
t.Helper() | ||
|
||
var message string | ||
if len(optionalMessage) > 0 { | ||
message = optionalMessage[0] | ||
} | ||
|
||
if !actual { | ||
t.Fatal("expected true, got false", message) | ||
} | ||
} | ||
|
||
// EqualSlices is a helper function to check equality of two slices. | ||
func EqualSlices[T1, T2 any](t *testing.T, expected []T1, actual []T2) { | ||
t.Helper() | ||
|
||
if len(expected) != len(actual) { | ||
t.Fatalf("expected slice length %d, got %d", len(expected), len(actual)) | ||
|
||
return | ||
} | ||
|
||
for i := range expected { | ||
if !reflect.DeepEqual(expected[i], actual[i]) { | ||
t.Fatalf("at index %d: expected %v, got %v", i, expected[i], actual[i]) | ||
} | ||
} | ||
} | ||
|
||
// Panics is a helper function to check if a function panics. | ||
func Panics(t *testing.T, fnc func(), optionalMessage ...string) { | ||
t.Helper() | ||
|
||
var message string | ||
if len(optionalMessage) > 0 { | ||
message = optionalMessage[0] | ||
} | ||
|
||
defer func() { | ||
if recover() == nil { | ||
t.Fatalf("expected panic, got nil %q", message) | ||
} | ||
}() | ||
|
||
fnc() | ||
} |
Oops, something went wrong.