Skip to content

Commit 4a78114

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 4a78114

File tree

8 files changed

+1435
-0
lines changed

8 files changed

+1435
-0
lines changed

.github/workflows/test.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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.21', '1.22', '1.23']
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.out -covermode=atomic
31+
32+
- name: Check coverage
33+
run: |
34+
coverage=$(go tool cover -func=coverage.out | 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.out
45+
fail_ci_if_error: false
46+
47+
lint:
48+
name: Lint
49+
runs-on: ubuntu-latest
50+
51+
steps:
52+
- name: Checkout code
53+
uses: actions/checkout@v4
54+
55+
- name: Set up Go
56+
uses: actions/setup-go@v5
57+
with:
58+
go-version: '1.23'
59+
60+
- name: Run golangci-lint
61+
uses: golangci/golangci-lint-action@v4
62+
with:
63+
version: latest

.gitignore

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

.golangci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
linters:
2+
enable-all: true
3+
disable:
4+
# Deprecated linters
5+
- exhaustivestruct
6+
- golint
7+
- ifshort
8+
- interfacer
9+
- maligned
10+
- scopelint
11+
- nosnakecase
12+
- structcheck
13+
- varcheck
14+
- deadcode
15+
16+
# Not needed for library
17+
- gochecknoglobals
18+
- gomnd
19+
- mnd
20+
- wrapcheck
21+
- exhaustruct
22+
- ireturn
23+
- varnamelen
24+
25+
linters-settings:
26+
lll:
27+
line-length: 120
28+
funlen:
29+
lines: 100
30+
statements: 50
31+
gocognit:
32+
min-complexity: 15
33+
cyclop:
34+
max-complexity: 15
35+
36+
issues:
37+
exclude-rules:
38+
# Allow long lines in tests
39+
- path: _test\.go
40+
linters:
41+
- lll
42+
- funlen
43+
- gocognit
44+
- cyclop
45+
46+
run:
47+
timeout: 5m
48+
tests: true

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)