Skip to content

Commit f4d87c2

Browse files
committed
feat: initial release
1 parent d854165 commit f4d87c2

File tree

11 files changed

+970
-412
lines changed

11 files changed

+970
-412
lines changed

.chglog/CHANGELOG.tpl.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{ range .Versions }}
2+
<a name="{{ .Tag.Name }}"></a>
3+
4+
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }}
5+
6+
{{ range .CommitGroups -}}
7+
8+
### {{ .Title }}
9+
10+
{{ range .Commits -}}
11+
12+
* {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
13+
{{ end }}
14+
{{ end -}}
15+
16+
{{- if .NoteGroups -}}
17+
{{ range .NoteGroups -}}
18+
19+
### {{ .Title }}
20+
21+
{{ range .Notes }}
22+
{{ .Body }}
23+
{{ end }}
24+
{{ end -}}
25+
{{ end -}}
26+
{{ end -}}

.chglog/config.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
style: github
2+
template: CHANGELOG.tpl.md
3+
info:
4+
title: CHANGELOG
5+
repository_url: https://github.com/jwplayer/ssai-go
6+
options:
7+
sort: "date"
8+
header:
9+
pattern: "^(\\w+)(?:\\(([^)]+)\\))?(?:!)?\\:[ \\t]*(.*)$"
10+
pattern_maps:
11+
- Type
12+
- Scope
13+
- Subject
14+
notes:
15+
keywords:
16+
- BREAKING CHANGES
17+
commit_groups:
18+
title_maps:
19+
feat: Features
20+
fix: Bug Fixes
21+
perf: Performance Improvements
22+
refactor: Code Refactoring
23+
chore: Chores
24+
ci: CI/CD
25+
docs: Documentation Updates
26+
test: Test Updates

.github/workflows/cd.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CD
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to release (format: x.y.z)'
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Install git-chglog
23+
run: |
24+
CHGLOG_VERSION="0.15.4"
25+
wget -O /tmp/git-chglog.tar.gz https://github.com/git-chglog/git-chglog/releases/download/v${CHGLOG_VERSION}/git-chglog_${CHGLOG_VERSION}_linux_amd64.tar.gz
26+
cd /tmp && tar xzf git-chglog.tar.gz
27+
sudo mv git-chglog /usr/local/bin/
28+
29+
- name: Setup Go
30+
uses: actions/setup-go@v5
31+
with:
32+
go-version: '1.24.0'
33+
34+
- name: Validate version format
35+
run: |
36+
if ! echo "${{ github.event.inputs.version }}" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$'; then
37+
echo "Invalid version format. Must be x.y.z"
38+
exit 1
39+
fi
40+
41+
- name: Generate changelog
42+
run: |
43+
git-chglog --output CHANGELOG.md --next-tag "v${{ github.event.inputs.version }}"
44+
45+
- name: Commit changelog
46+
run: |
47+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
48+
git config --local user.name "GitHub Actions"
49+
git add CHANGELOG.md
50+
git commit -m "chore: update changelog"
51+
git push
52+
53+
- name: Create tag
54+
run: |
55+
git tag "v${{ github.event.inputs.version }}"
56+
git push origin "v${{ github.event.inputs.version }}"
57+
58+
- name: Run GoReleaser
59+
uses: goreleaser/goreleaser-action@v5
60+
with:
61+
distribution: goreleaser
62+
version: latest
63+
args: release --clean
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*'
7+
branches:
8+
- main
9+
pull_request:
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
lints:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version: 1.24.0
22+
check-latest: true
23+
- uses: golangci/golangci-lint-action@v6
24+
env:
25+
# Go includes VCS data since v1.20 and this
26+
# can cause problems with CI checkout.
27+
# This information shouldn't be necessary for CI anyway.
28+
GOFLAGS: "-buildvcs=false"
29+
with:
30+
version: v1.62.2
31+
# --concurrency 0 automatically matches Linux container CPU quota.
32+
args: --timeout 10m --concurrency 0
33+
34+
tests:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v4
38+
- uses: actions/setup-go@v5
39+
with:
40+
go-version: 1.24.0
41+
check-latest: true
42+
- name: Run tests and calculate coverage
43+
run: go test -v -covermode=count -coverprofile=coverage.out
44+
45+
static-checks:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: actions/setup-go@v5
50+
with:
51+
go-version: 1.24.0
52+
check-latest: true
53+
- id: govulncheck
54+
uses: golang/govulncheck-action@v1
55+
with:
56+
go-version-input: 1.24.0

.goreleaser.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
project_name: bitset
2+
before:
3+
hooks:
4+
- go mod tidy
5+
snapshot:
6+
name_template: "{{ .Tag }}"
7+
release:
8+
draft: false
9+
replace_existing_draft: true
10+
prerelease: false
11+
mode: append
12+
header: |
13+
## Release {{ .Tag }} ({{ .Date }})
14+
15+
See [CHANGELOG.md](CHANGELOG.md) for details.
16+
changelog:
17+
disable: true

LICENSE

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
BSD 2-Clause License
2+
3+
Copyright (c) 2025, Daniil Trishkin
4+
Copyright (c) 2017, Stefan Nilsson
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without
8+
modification, are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice, this
11+
list of conditions and the following disclaimer.
12+
13+
* Redistributions in binary form must reproduce the above copyright notice,
14+
this list of conditions and the following disclaimer in the documentation
15+
and/or other materials provided with the distribution.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# ⚡ BitSet ⚡
2+
3+
This is a simple, though very fast, bitset implementation in Go derived from the [yourbasic/bit](github.com/yourbasic/bit) package.
4+
5+
## Installation
6+
7+
```go
8+
go get github.com/KernelPryanic/bitset
9+
```
10+
11+
## Usage
12+
13+
### Creating BitSets
14+
15+
```go
16+
// Create an empty bitset
17+
empty := bitset.New()
18+
19+
// Create a bitset with initial values
20+
set := bitset.New(1, 3, 5, 7)
21+
```
22+
23+
### Basic Operations
24+
25+
```go
26+
// Add elements
27+
set.Add(9) // Add single element
28+
set.AddRange(2, 5) // Add range [2,3,4]
29+
30+
// Check membership
31+
exists := set.Contains(3) // true
32+
absent := set.Contains(6) // false
33+
34+
// Remove elements
35+
set.Delete(3) // Remove single element
36+
set.DeleteRange(2, 5) // Remove range [2,3,4]
37+
38+
// Get set information
39+
size := set.Size() // Number of elements
40+
isEmpty := set.Empty() // Check if set is empty
41+
max := set.Max() // Get maximum element
42+
43+
// Iterate through elements
44+
set.Visit(func(n int) bool {
45+
fmt.Printf("%d ", n)
46+
return false // Return true to stop iteration
47+
})
48+
```
49+
50+
### Set Operations
51+
52+
```go
53+
set1 := bitset.New(1, 2, 3, 4, 5)
54+
set2 := bitset.New(4, 5, 6, 7, 8)
55+
56+
// Create new sets from operations
57+
intersection := bitset.And(set1, set2) // Elements in both sets
58+
union := bitset.Or(set1, set2) // Elements in either set
59+
symDiff := bitset.Xor(set1, set2) // Elements in one set but not both
60+
diff := bitset.AndNot(set1, set2) // Elements in set1 but not in set2
61+
62+
// Modify existing sets
63+
set1.And(set2) // Keep only elements present in both sets
64+
set1.Or(set2) // Add all elements from set2
65+
set1.Xor(set2) // Keep elements present in one set but not both
66+
set1.AndNot(set2) // Remove all elements present in set2
67+
```
68+
69+
### Navigation
70+
71+
```go
72+
set := bitset.New(1, 3, 5, 7, 9)
73+
74+
// Find next/previous elements
75+
next := set.Next(4) // Returns 5 (next element after 4)
76+
prev := set.Prev(6) // Returns 5 (previous element before 6)
77+
78+
// Copy sets
79+
copy := set.Copy() // Create a new copy
80+
set2 := bitset.New()
81+
set2.Set(set) // Replace contents of set2 with set
82+
```
83+
84+
### String Representation
85+
86+
```go
87+
set := bitset.New(1, 2, 3, 5, 7, 8, 9, 10)
88+
fmt.Println(set) // Outputs: {1..3 5 7..10}
89+
```

0 commit comments

Comments
 (0)