Skip to content

Commit 8d712a7

Browse files
committed
feat: concurrent and non concurrent set implementation
1 parent 2f2813b commit 8d712a7

File tree

10 files changed

+1029
-2
lines changed

10 files changed

+1029
-2
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lint and Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Install Go
12+
uses: actions/setup-go@v5
13+
with:
14+
go-version: 1.24.x
15+
16+
- name: Linter
17+
uses: golangci/golangci-lint-action@v7
18+
with:
19+
args: --timeout=5m
20+
21+
- name: Run unit tests
22+
run: go test -v ./... --tags=unit -coverpkg=./...
23+
24+
- name: Run integration tests
25+
run: go test -v ./... --tags=integration -coverpkg=./...

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
TODO.md
2+
3+
# GO
4+
# ref: https://github.com/github/gitignore/blob/main/Go.gitignore
5+
6+
*.dll
7+
*.dylib
8+
*.exe
9+
*.exe~
10+
*.out
11+
*.so
12+
*.test
13+
go.work
14+
go.work.sum
15+
dist/

.golangci.yaml

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
version: "2"
2+
linters:
3+
enable:
4+
- asciicheck
5+
- bodyclose
6+
- copyloopvar
7+
- dogsled
8+
- durationcheck
9+
- err113
10+
- errorlint
11+
- exhaustive
12+
- funlen
13+
- gochecknoglobals
14+
- gochecknoinits
15+
- gocognit
16+
- goconst
17+
- gocritic
18+
- gocyclo
19+
- godox
20+
- goprintffuncname
21+
- gosec
22+
- iface
23+
- inamedparam
24+
- lll
25+
- misspell
26+
- nestif
27+
- noctx
28+
- nolintlint
29+
- perfsprint
30+
- prealloc
31+
- reassign
32+
- revive
33+
- sloglint
34+
- staticcheck
35+
- testpackage
36+
- tparallel
37+
- unconvert
38+
- unparam
39+
- usestdlibvars
40+
- whitespace
41+
- wsl
42+
settings:
43+
cyclop:
44+
max-complexity: 15
45+
package-average: 10
46+
dupl:
47+
threshold: 100
48+
errcheck:
49+
check-type-assertions: true
50+
check-blank: true
51+
errorlint:
52+
errorf: true
53+
asserts: true
54+
comparison: true
55+
exhaustive:
56+
check:
57+
- switch
58+
- map
59+
default-signifies-exhaustive: false
60+
funlen:
61+
lines: 100
62+
statements: 50
63+
ignore-comments: true
64+
gocognit:
65+
min-complexity: 21
66+
goconst:
67+
min-len: 2
68+
min-occurrences: 2
69+
gocritic:
70+
settings:
71+
captLocal:
72+
paramsOnly: false
73+
underef:
74+
skipRecvDeref: false
75+
gocyclo:
76+
min-complexity: 15
77+
godox:
78+
keywords:
79+
- BUG
80+
- FIXME
81+
- DEBUG
82+
govet:
83+
disable:
84+
- fieldalignment
85+
enable-all: true
86+
settings:
87+
shadow:
88+
strict: true
89+
inamedparam:
90+
skip-single-param: true
91+
lll:
92+
line-length: 150
93+
misspell:
94+
locale: US
95+
mnd:
96+
ignored-functions:
97+
- args.Error
98+
- flag.Arg
99+
- flag.Duration.*
100+
- flag.Float.*
101+
- flag.Int.*
102+
- flag.Uint.*
103+
- os.Chmod
104+
- os.Mkdir.*
105+
- os.OpenFile
106+
- os.WriteFile
107+
nolintlint:
108+
require-explanation: true
109+
require-specific: true
110+
perfsprint:
111+
strconcat: false
112+
reassign:
113+
patterns:
114+
- .*
115+
sloglint:
116+
no-mixed-args: false
117+
kv-only: false
118+
attr-only: true
119+
no-global: all
120+
static-msg: true
121+
no-raw-keys: false
122+
key-naming-case: snake
123+
args-on-sep-lines: true
124+
whitespace:
125+
multi-if: false
126+
multi-func: false
127+
wsl:
128+
strict-append: true
129+
allow-assign-and-call: true
130+
allow-assign-and-anything: false
131+
allow-multiline-assign: true
132+
force-case-trailing-whitespace: 0
133+
allow-trailing-comment: false
134+
allow-separated-leading-comment: false
135+
allow-cuddle-declarations: false
136+
force-err-cuddling: false
137+
force-short-decl-cuddling: false
138+
exclusions:
139+
generated: lax
140+
rules:
141+
- linters:
142+
- funlen
143+
- gochecknoglobals
144+
- gosec
145+
- mnd
146+
path: _test\.go
147+
- linters:
148+
- gocritic
149+
text: 'unnecessaryDefer:'
150+
- linters:
151+
- govet
152+
text: 'shadow: declaration of "(err|ctx)" shadows declaration at'
153+
- path: (.+)\.go$
154+
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
155+
- path: (.+)\.go$
156+
text: (possible misuse of unsafe.Pointer|should have signature)
157+
- path: (.+)\.go$
158+
text: Use of unsafe calls should be audited
159+
- path: (.+)\.go$
160+
text: Subprocess launch(ed with variable|ing should be audited)
161+
- path: (.+)\.go$
162+
text: (G104|G307)
163+
- path: (.+)\.go$
164+
text: (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
165+
- path: (.+)\.go$
166+
text: Potential file inclusion via variable
167+
- path: (.+)\.go$
168+
text: (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
169+
- path: (.+)\.go$
170+
text: .*\.pb\.go$
171+
paths:
172+
- .git
173+
- .github
174+
formatters:
175+
enable:
176+
- gofmt
177+
- goimports
178+
settings:
179+
gofmt:
180+
simplify: true
181+
rewrite-rules:
182+
- pattern: interface{}
183+
replacement: any
184+
- pattern: a[b:len(a)]
185+
replacement: a[b:]
186+
exclusions:
187+
generated: lax
188+
paths:
189+
- .git
190+
- .github

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.DEFAULT_GOAL := help
2+
3+
.PHONY: help
4+
help: ## This help.
5+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
6+
7+
.PHONY: lint
8+
lint: ## Run golangci-lint fixing issues
9+
golangci-lint run --fix
10+
11+
.PHONY: tests
12+
tests: ## Run tests
13+
go test ./... --tags=unit,integration -coverpkg=./...

README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,42 @@
1-
# goset
2-
Goset is a Go library that provides a simple and efficient way to work withgeneric sets. It offers both a concurrent and no concurrent implementation.
1+
# Goset
2+
3+
## Description
4+
Goset is a Go library that provides a simple and efficient way to work with [generic](https://go.dev/blog/intro-generics) sets. It allows you to create, manipulate, and perform operations on sets. It offers both a concurrent and no concurrent implementation, allowing you to choose the one that best fits your needs.
5+
6+
## Features
7+
- Create sets of [comparable](https://go.dev/blog/comparable) elements.
8+
- Perform set operations such as union, intersection, and difference.
9+
10+
## Example
11+
```go
12+
package main
13+
14+
import (
15+
"fmt"
16+
"github.com/yourusername/goset"
17+
)
18+
19+
func main() {
20+
// Create a new set
21+
s := goset.NewSet[int]()
22+
23+
// Add elements to the set
24+
s.Add(1)
25+
s.Add(2)
26+
s.Add(3)
27+
28+
// Check if an element is in the set
29+
fmt.Println(s.Contains(2)) // true
30+
31+
// Remove an element from the set
32+
s.Remove(2)
33+
34+
// Get the size of the set
35+
fmt.Println(s.Size()) // 2
36+
37+
// Iterate over the elements in the set
38+
for _, v := range s.Values() {
39+
fmt.Println(v) // 1, 3
40+
}
41+
}
42+
```

0 commit comments

Comments
 (0)