Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[codespell]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note: I would not recommend using codespell as it finds almost no errors.
My suggestion have a look at tt and tt-ee where cSpell is used via pre-commit.
And in general, it would be very good if you could immediately run hooks checks when you commit new code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make it in separate PR


skip = ./vendor,./.git
# ignore-words-list =
check-filenames = true
9 changes: 9 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
What has been done? Why? What problem is being solved?

I didn't forget about (remove if it is not applicable):

- [ ] Tests (see [documentation](https://pkg.go.dev/testing) for a testing package)
- [ ] Changelog (see [documentation](https://keepachangelog.com/en/1.0.0/) for changelog format)
- [ ] Documentation (see [documentation](https://go.dev/blog/godoc) for documentation style guide)

Related issues:
72 changes: 72 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Run checks

on:
push:
pull_request:

env:
GO_VERSION: 1.24
CODESPELL_VERSION: v2.4.1


jobs:
golangci-lint:
runs-on: ubuntu-latest
if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- uses: golangci/golangci-lint-action@v8
name: run golangci-lint with gha format
continue-on-error: true

- uses: golangci/golangci-lint-action@v8
name: run golangci-lint with human-readable format

codespell:
runs-on: ubuntu-latest
if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository

steps:
- uses: actions/checkout@v4

- name: install codespell
run: pip3 install codespell==${CODESPELL_VERSION}

- name: run codespell
run: make codespell

verify-generation:
runs-on: ubuntu-latest
if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: genrate code
run: go generate ./...

- name: check for changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "new files were generated"
git status --porcelain
git diff
exit 1
fi
65 changes: 65 additions & 0 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: testing

on:
push:
pull_request:
workflow_dispatch:

jobs:
run-tests:
if: (github.event_name == 'push') ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository) ||
(github.event_name == 'workflow_dispatch')

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
golang: ['1.23', 'stable']

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.golang }}

- name: run tests
run: make test

- name: run tests with race
run: make testrace

run-tests-with-coverage:
if: (github.event_name == 'push') ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository) ||
(github.event_name == 'workflow_dispatch')

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.golang }}

- name: run tests, collect code coverage data and send to Coveralls
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make coverage coveralls-deps coveralls

run-benchmarks:
if: false

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.golang }}
- name: run benchmarks
run: make bench

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage.out
29 changes: 29 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '2'

run:
timeout: 3m

formatters:
enable:
- goimports

linters:
enable:
- forbidigo
- gocritic
- lll
- reassign
- unconvert
- gosec
- errorlint
- godot
- revive
- testpackage
- unused

settings:
godot:
scope: all
lll:
line-length: 120
tab-width: 4
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
GOTEST := go test
TAGS :=
COVERAGE_FILE := coverage.out

.PHONY: codespell
codespell:
@echo "Running codespell"
@codespell

.PHONY: test
test:
@echo "Running tests"
@go test ./... -count=1

.PHONY: testrace
testrace:
@echo "Running tests with race flag"
@go test ./... -count=100 -race

.PHONY: coverage
coverage:
@echo "Running tests with coveralls"
go test -tags "$(TAGS)" $(go list ./... | grep -v test_helpers) -v -p 1 -covermode=atomic -coverprofile=$(COVERAGE_FILE) -count=1
go tool cover -func=$(COVERAGE_FILE)

.PHONY: coveralls
coveralls:
@echo "uploading coverage to coveralls"
@goveralls -coverprofile=$(COVERAGE_FILE) -service=github

.PHONY: coveralls-deps
coveralls-deps:
@echo "Installing coveralls"
@go get github.com/mattn/goveralls
@go install github.com/mattn/goveralls
8 changes: 8 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Package option provides a type-safe way to represent optional values in Go.
// An Optional[T] can either contain a value of type T (Some) or be empty (None).
//
// This is useful for:
// - Clearly representing nullable fields in structs.
// - Avoiding nil pointer dereferences.
// - Providing explicit intent about optional values.
package option
Empty file added go.sum
Empty file.