-
Notifications
You must be signed in to change notification settings - Fork 0
chore: improve docs, tooling, tests, and dev environment #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // For format details, see https://aka.ms/devcontainer.json. | ||
| { | ||
| "name": "Ubuntu", | ||
| // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
| "image": "mcr.microsoft.com/devcontainers/base:ubuntu", | ||
| // Features to add to the dev container. More info: https://containers.dev/features. | ||
| "features": { | ||
| "ghcr.io/devcontainers-extra/features/mise:1": {}, | ||
| "ghcr.io/devcontainers/features/docker-in-docker:2": {} | ||
| }, | ||
| "postCreateCommand": "bash .devcontainer/post_create.sh", | ||
| "customizations": { | ||
| "vscode": { | ||
| "extensions": [ | ||
| "golang.go" | ||
| ] | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #!/bin/bash | ||
|
|
||
| # note that bash will read from ~/.profile or ~/.bash_profile if the latter exists | ||
| # ergo, you may want to check to see which is defined on your system and only append to the existing file | ||
| echo 'eval "$(mise activate bash --shims)"' >>~/.bash_profile # this sets up non-interactive sessions | ||
| echo 'eval "$(mise activate bash)"' >>~/.bashrc # this sets up interactive sessions | ||
|
|
||
| mise trust . | ||
|
|
||
| mise install | ||
|
|
||
| mise exec -- go install -v golang.org/x/tools/gopls@latest | ||
| mise exec -- go install -v github.com/go-delve/delve/cmd/dlv@latest | ||
|
min0625 marked this conversation as resolved.
|
||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: PR Check | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| check: | ||
| name: Lint & Test | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Install mise | ||
| uses: jdx/mise-action@v4 | ||
|
|
||
| - name: Download Go dependencies | ||
| run: go mod download | ||
|
|
||
| - name: Run check (lint + test) | ||
| run: make check |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| // Use IntelliSense to learn about possible attributes. | ||
| // Hover to view descriptions of existing attributes. | ||
| // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
| "version": "0.2.0", | ||
| "configurations": [ | ||
| { | ||
| "name": "Launch test function", | ||
| "type": "go", | ||
| "request": "launch", | ||
| "mode": "test", | ||
| "program": "${workspaceFolder}", | ||
| "args": [ | ||
| "-test.run", | ||
| "MyTestFunction" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "Launch Workspace", | ||
| "type": "go", | ||
| "request": "launch", | ||
| "mode": "debug", | ||
| "program": "${workspaceFolder}", | ||
| "cwd": "${workspaceFolder}", | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "go.useLanguageServer": true, | ||
| "go.toolsManagement.autoUpdate": true, | ||
| "go.lintTool": "golangci-lint-v2", | ||
| "go.lintFlags": [ | ||
| "--path-mode=abs", | ||
| "--fast-only" | ||
| ], | ||
| "go.alternateTools": { | ||
| "customFormatter": "golangci-lint-v2" | ||
| }, | ||
| "go.formatTool": "custom", | ||
| "go.formatFlags": [ | ||
| "fmt", | ||
| "--stdin" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| # AGENTS.md | ||
|
|
||
| This file provides instructions and conventions for AI coding agents working in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| `github.com/min0625/errgroup` is a Go library that extends [`golang.org/x/sync/errgroup`](https://pkg.go.dev/golang.org/x/sync/errgroup) with panic recovery. Panics occurring in goroutines started by `Go` or `TryGo` are caught and re-panicked inside `Wait`, wrapped as `PanicError` or `PanicValue`. | ||
|
|
||
| ### Packages | ||
|
|
||
| | Path | Module path | Description | | ||
| |------|-------------|-------------| | ||
| | `/` (root) | `github.com/min0625/errgroup` | Drop-in replacement for `golang.org/x/sync/errgroup` | | ||
| | `x/errgroup/` | `github.com/min0625/errgroup/x/errgroup` | Context-aware variant — passes `context.Context` into each goroutine function | | ||
|
|
||
| ## Repository Structure | ||
|
|
||
| ``` | ||
| errgroup.go # Core Group type and methods | ||
| panic.go # PanicError, PanicValue types and exception() helper | ||
| errgroup_test.go # Tests for the root package | ||
| example_test.go # Runnable examples for the root package | ||
| go.mod # Module definition | ||
| Makefile # Developer commands | ||
| mise.toml # Pinned tool versions (Go, golangci-lint) | ||
| x/errgroup/ | ||
| errgroup.go # Context-aware Group type | ||
| panic.go # Re-exports panic types from the root package (if any) | ||
| errgroup_test.go # Tests for the x/errgroup package | ||
| example_test.go # Runnable examples for the x/errgroup package | ||
| ``` | ||
|
|
||
| ## Tool Versions | ||
|
|
||
| Tool versions are pinned in `mise.toml`. Install them with: | ||
|
|
||
| ```sh | ||
| mise install | ||
| ``` | ||
|
|
||
| | Tool | Version | | ||
| |------|---------| | ||
| | Go | 1.24.x | | ||
| | golangci-lint | 2.x | | ||
|
|
||
| ## Common Commands | ||
|
|
||
| All commands should be run from the repository root. | ||
|
|
||
| | Command | Description | | ||
| |---------|-------------| | ||
| | `make fmt` | Format all Go source files via `golangci-lint fmt` | | ||
| | `make lint` | Run linter (`golangci-lint run`) | | ||
| | `make fix` | Run linter with auto-fix (`golangci-lint run --fix`) | | ||
| | `make test` | Run all tests with race detector (`go test -v -race -failfast ./...`) | | ||
| | `make check` | Run `lint` then `test` (full CI gate) | | ||
|
|
||
| Always run `make check` before considering a change complete. | ||
|
|
||
| ## Development Guidelines | ||
|
|
||
| ### Code Style | ||
|
|
||
| - Follow standard Go conventions (`gofmt`, `goimports`). | ||
| - Use `make fmt` to format code; do not manually reformat. | ||
| - Exported symbols must have GoDoc comments. Keep them concise and consistent with the existing style. | ||
| - Internal helpers (unexported) should be commented only when non-obvious. | ||
|
|
||
| ### Testing | ||
|
|
||
| - All new behaviour must have corresponding tests. | ||
| - Tests must be parallel where possible (`t.Parallel()`). | ||
| - Use [`github.com/stretchr/testify`](https://pkg.go.dev/github.com/stretchr/testify) (`assert`, `require`) — consistent with the existing test suite. | ||
| - Run tests with the race detector: `make test` (uses `-race` flag). | ||
| - Place tests in `_test` package (external test package), e.g. `package errgroup_test`. | ||
|
|
||
| ### Panic Handling | ||
|
|
||
| - `PanicError` wraps recovered values that implement `error`. | ||
| - `PanicValue` wraps all other recovered values. | ||
| - Both expose a `Stack []byte` field with the captured stack trace. | ||
| - When multiple goroutines panic concurrently, only the first panic is propagated; the rest are silently discarded. Preserve this invariant. | ||
|
|
||
| ### Dual-Package Consistency | ||
|
|
||
| Changes to the root package (`errgroup.go`, `panic.go`) that affect the public API or panic-recovery behaviour must be reflected in `x/errgroup/` where applicable, and vice versa. | ||
|
|
||
| ### Dependencies | ||
|
|
||
| - Keep dependencies minimal. The only non-test runtime dependency is `golang.org/x/sync`. | ||
| - Run `go mod tidy` after adding or removing imports. | ||
|
|
||
| ### Linting | ||
|
|
||
| - The project uses `golangci-lint`. Lint rules are configured in the repository (check for `.golangci.yml` or inline `//nolint` directives). | ||
| - Suppress a lint warning with `//nolint:<linter> // <reason>` only when genuinely necessary, not to silence legitimate issues. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,13 @@ | ||
| MODULE_DIRS = . | ||
|
|
||
| gowork: | ||
| go work init . | ||
|
|
||
| tidy: | ||
| go mod tidy | ||
|
|
||
| install-asdf: | ||
| -asdf install | ||
|
|
||
| install: install-asdf tidy | ||
| # curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v2.5.0 | ||
|
|
||
| fmt: install | ||
| fmt: | ||
| golangci-lint fmt -v ./... | ||
|
|
||
| fix: install | ||
| fix: | ||
| golangci-lint run -v --fix ./... | ||
|
|
||
| lint: install | ||
| lint: | ||
| golangci-lint run -v ./... | ||
|
|
||
| test: install | ||
| test: | ||
| go test -v -race -failfast ./... | ||
|
|
||
| check: fix lint test | ||
| check: lint test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.