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
12 changes: 12 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

export DIRENV_WARN_TIMEOUT=20s

eval "$(devenv direnvrc)"

# `use devenv` supports the same options as the `devenv shell` command.
#
# To silence all output, use `--quiet`.
#
# Example usage: use devenv --quiet --impure --option services.postgres.enable:bool true
use devenv
4 changes: 2 additions & 2 deletions .github/actions/prepare/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ runs:
using: "composite"
steps:
- name: setup golang
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: clear go mod cache
run: sudo rm -rf $GOMODCACHE
shell: bash
- name: connect go mod cache
id: cache-gomod
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: /tmp/go/pkg/mod
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: setup golang
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: clear go mod cache
run: sudo rm -rf $GOMODCACHE
- name: connect go mod cache
id: cache-gomod
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: /tmp/go/pkg/mod
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: prepare
uses: ./.github/actions/prepare
- name: setup golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v9
with:
version: v1.60.3
version: v2.6
- name: run golangci-lint
run: golangci-lint run
10 changes: 5 additions & 5 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: prepare
uses: ./.github/actions/prepare
- name: run tests
run: go test -v -covermode atomic ./... --race --timeout 1m
run: go test -v -race -timeout=1m -covermode=atomic ./...
integration:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: prepare
uses: ./.github/actions/prepare
- name: run tests
run: go test -v ./test/... --race --timeout 1m -tags=integration
run: go test -v -race -timeout=1m -tags=integration ./test/...
ws-autobahn:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: prepare
uses: ./.github/actions/prepare
- name: make report directory
Expand Down
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ go.work
# IDE files
.idea/


# Devenv
.devenv*
devenv.local.nix
devenv.local.yaml

# direnv
.direnv

# pre-commit
.pre-commit-config.yaml
130 changes: 12 additions & 118 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,125 +1,19 @@
version: "2"

run:
timeout: 5m
issues-exit-code: 1
tests: false
modules-download-mode: readonly
allow-parallel-runners: true

output:
print-issued-lines: true
print-linter-name: true

linters:
disable:
- depguard
- exhaustruct
- fatcontext
- gochecknoglobals
- goconst
- godot
- godox
- nonamedreturns
- nlreturn
- varnamelen
- inamedparam
- wsl
- wrapcheck
presets:
- bugs
- comment
- complexity
- error
- format
- import
- metalinter
- module
- performance
- style
- test
- unused

linters-settings:
exhaustive:
ignore-enum-members: '^*(Unspecified|Undefined|Unknown|Idle)$'
cyclop:
max-complexity: 20
gomnd:
ignored-numbers:
- '2'
- '4'
- '8'
- '16'
- '32'
- '64'
gci:
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/einouqo/ext-kit) # Custom section: groups all imports with the specified Prefix.
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
- dot
tagliatelle:
case:
rules:
json: snake
yaml: snake
exclusions:
rules:
# an exception, as the error value is used to signal the end of the stream
- linters:
- staticcheck
source: "StreamDone"
# as documentation states: "... This method always returns a nil error" https://github.com/grpc/grpc-go/blob/v1.78.0/stream.go#L105-L108
- linters:
- errcheck
source: "defer .*\\.CloseSend()"

Comment on lines +1 to 19
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

The .golangci.yml config has been dramatically simplified from a comprehensive configuration to minimal exclusions. While this may be intentional, it removes all linter presets, custom settings, and most exclusion rules that were previously in place. This could lead to many new linting errors appearing. Consider whether this level of simplification is intended, or if key configurations should be retained.

Copilot uses AI. Check for mistakes.
issues:
exclude-dirs:
- test # no lints for tests
exclude-files:
- .*_test.go$ # unit tests
- transport/ws/intercepting_writer.go # code from http package of go-kit project (https://github.com/go-kit/kit/blob/master/transport/http/intercepting_writer.go).
exclude-rules:
- linters:
- wrapcheck
text: 'error returned from interface method should be wrapped'
source: ^*return .*
- linters:
- wrapcheck
text: ^error returned from external package is unwrapped[:] .*multierror.* error$
- linters:
- wrapcheck
source: .*status.Error\(.*, .*\).*
- linters:
- cyclop
text: 'calculated cyclomatic complexity for function'
source: ^func \(.*\) String\(\) string {$
- linters:
- gomnd
source: .*(time\..|[0-9]+<<[0-9]+)*$
- linters:
- gofumpt
source: ^var \(
- linters:
- unparam
# except setters with self returning
text: .*\)\.set([A-z0-9]+)? - result 0 \(\*.*\) is never used$
- linters:
- gosec
text: 'G109:'
- linters:
- gosec
text: 'G404:'
- linters:
- lll
source: .*// .*
- linters:
- stylecheck
text: 'ST1012:'
- linters:
- forbidigo
text: use of `fmt\..*` forbidden by pattern `.*`$
- path: transport # ok for transport
linters: [ gocognit, gocyclo, cyclop, forcetypeassert, funlen, ireturn, lll ]
- path: endpoint
linters: [ errname, revive ]
- linters:
- gocritic
text: 'appendAssign: append result not assigned to the same slice'
- linters:
- errcheck
source: ^\s*defer .*$
- linters:
- revive
text: 'if-return: redundant if ...;'
44 changes: 24 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Go ext kit

![Go Version](https://img.shields.io/badge/go-1.22+-blue.svg)
![Go Version](https://img.shields.io/github/go-mod/go-version/einouqo/ext-kit)
[![Go Report Card](https://goreportcard.com/badge/github.com/einouqo/ext-kit)](https://goreportcard.com/report/github.com/einouqo/ext-kit)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Expand Down Expand Up @@ -32,40 +32,43 @@ go get github.com/einouqo/ext-kit
You can refer to the [tests](test/transport/grpc) for more examples.

**Server:**

```go
type Service interface {
Bi(ctx context.Context, receiver <-chan string) (endpoint.Receive[string], error)
Bi(ctx context.Context, receiver <-chan string) (endpoint.Receive[string], error)
}

func NewServerBinding(svc Service, opts ...kitgrpc.ServerOption) *ServerBinding {
return &ServerBinding{
/* ... */
biStream: kitgrpc.NewServerBiStream[*pb.EchoRequest](
svc.Bi,
decodeRequest,
encodeResponse,
opts...,
),
}
return &ServerBinding{
/* ... */
biStream: kitgrpc.NewServerBiStream[*pb.EchoRequest](
svc.Bi,
decodeRequest,
encodeResponse,
opts...,
),
}
}
```

**Client:**

```go
func NewClientBinding(cc *grpc.ClientConn) *ClientBinding {
return &ClientBinding{
/* ... */
BiStream: kitgrpc.NewClientBiStream[*pb.EchoResponse](
cc,
pb.Echo_BiStream_FullMethodName,
encodeRequest,
decodeResponse,
).Endpoint(),
}
return &ClientBinding{
/* ... */
BiStream: kitgrpc.NewClientBiStream[*pb.EchoResponse](
cc,
pb.Echo_BiStream_FullMethodName,
encodeRequest,
decodeResponse,
).Endpoint(),
}
}
```

Make a call:

```go
send := make(chan service.EchoRequest) // send your requests to the channel in the way you want
receive, err := client.BiStream(ctx, send)
Expand All @@ -85,6 +88,7 @@ for {
```

#### WebSocket

The usage is pretty close to gRPC Bi-Directional Streaming (the example above), but with WebSocket transport inside.

You can also refer to the [tests](test/transport/ws) or [autobahn](test/transport/autobahn) implementation for more examples.
Expand Down
Loading
Loading