Skip to content

Commit 691dfa5

Browse files
committed
Initial commit: Thread-safe ordered map for Go
- Insertion order preservation with O(1) lookups - Thread-safe with RWMutex - Zero-value usable - Generic support (Go 1.18+) - Snapshot-based iteration (deadlock-free) - 100% test coverage with race detection
0 parents  commit 691dfa5

File tree

11 files changed

+2862
-0
lines changed

11 files changed

+2862
-0
lines changed

.github/workflows/test.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
go-version: ['1.22', '1.23', '1.24']
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: ${{ matrix.go-version }}
25+
26+
- name: Download dependencies
27+
run: go mod download
28+
29+
- name: Run tests
30+
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic
31+
32+
- name: Check coverage
33+
run: |
34+
coverage=$(go tool cover -func=coverage.txt | grep total | awk '{print $3}' | sed 's/%//')
35+
echo "Coverage: $coverage%"
36+
if (( $(echo "$coverage < 100" | bc -l) )); then
37+
echo "Error: Coverage is below 100%"
38+
exit 1
39+
fi
40+
41+
- name: Upload coverage to Codecov
42+
uses: codecov/codecov-action@v4
43+
with:
44+
files: ./coverage.txt
45+
fail_ci_if_error: false
46+
token: ${{ secrets.CODECOV_TOKEN }}
47+
48+
lint:
49+
name: Lint
50+
runs-on: ubuntu-latest
51+
52+
steps:
53+
- name: Checkout code
54+
uses: actions/checkout@v4
55+
56+
- name: Set up Go
57+
uses: actions/setup-go@v5
58+
with:
59+
go-version: '1.24'
60+
61+
- name: Install golangci-lint
62+
run: go install github.com/golangci/golangci-lint/cmd/[email protected]
63+
64+
- name: Verify golangci-lint config
65+
run: golangci-lint config verify
66+
67+
- name: Run golangci-lint
68+
run: golangci-lint run --timeout=5m ./...

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Binaries
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary
9+
*.test
10+
11+
# Coverage
12+
coverage.txt
13+
coverage.out
14+
coverage.html
15+
16+
# Dependency directories
17+
vendor/
18+
19+
# Go workspace
20+
go.work
21+
go.work.sum
22+
23+
# IDE
24+
.idea/
25+
.vscode/
26+
*.swp
27+
*.swo
28+
*~
29+
30+
# OS
31+
.DS_Store
32+
Thumbs.db

.golangci.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# golangci-lint configuration
2+
# v2.5.0-ready: explicit, stable linter set + v2 formatters
3+
4+
version: "2"
5+
6+
run:
7+
timeout: 5m
8+
tests: true
9+
10+
# Formatters live here in v2 (not in linters.enable)
11+
formatters:
12+
enable:
13+
- gofumpt
14+
- gofmt
15+
- goimports
16+
settings:
17+
goimports:
18+
local-prefixes:
19+
- github.com/ndbroadbent/db_cutover_orchestrator
20+
gofumpt:
21+
extra-rules: true
22+
module-path: github.com/ndbroadbent/db_cutover_orchestrator
23+
24+
linters:
25+
default: none
26+
enable:
27+
# Core analysis (default enabled linters)
28+
- govet
29+
- staticcheck
30+
- errcheck
31+
- ineffassign
32+
- unused
33+
34+
# Error handling
35+
- nilerr
36+
- forcetypeassert
37+
38+
# Code quality
39+
- revive
40+
- gocritic
41+
42+
# Bugs/correctness
43+
- bodyclose
44+
- contextcheck
45+
- copyloopvar # v2 replacement for exportloopref
46+
- noctx
47+
48+
# Performance
49+
- prealloc
50+
51+
# Complexity
52+
- funlen
53+
- gocognit
54+
- gocyclo
55+
56+
# Security / policy
57+
- gosec
58+
- forbidigo
59+
- depguard
60+
61+
# Style
62+
- lll
63+
64+
exclusions:
65+
rules:
66+
# Allow longer test functions and some duplication in tests
67+
- path: _test\.go
68+
linters:
69+
- funlen
70+
- dupl
71+
- forbidigo
72+
- gosec
73+
- gocognit
74+
# Allow fmt.Print* in CLI commands (legitimate stdout output)
75+
- path: internal/cmd/
76+
linters:
77+
- forbidigo
78+
# Allow file operations in config and state packages
79+
- path: internal/(config|state)/
80+
text: "G304.*file inclusion"
81+
linters:
82+
- gosec
83+
84+
settings:
85+
lll:
86+
line-length: 120
87+
tab-width: 1
88+
89+
funlen:
90+
lines: 100
91+
statements: 50
92+
93+
gocognit:
94+
min-complexity: 15
95+
96+
gocyclo:
97+
min-complexity: 15
98+
99+
forbidigo:
100+
forbid:
101+
- pattern: '^fmt\.Print.*'
102+
msg: "use proper logging instead of fmt.Print"
103+
- pattern: "^panic"
104+
msg: "use error returns instead of panic"
105+
- pattern: '^time\.Sleep'
106+
msg: "use context with timeout instead of time.Sleep"
107+
exclude-godoc-examples: true
108+
analyze-types: true
109+
110+
depguard:
111+
rules:
112+
main:
113+
list-mode: lax
114+
files: [$all]
115+
allow:
116+
- $gostd
117+
- github.com/ndbroadbent/db_cutover_orchestrator
118+
deny:
119+
- pkg: io/ioutil$
120+
desc: "use io or os instead"
121+
122+
issues:
123+
max-issues-per-linter: 0
124+
max-same-issues: 0

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 DocSpring, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)