Skip to content

Commit aee5e5c

Browse files
committed
fix: some fixes
perf: change to dirt make fix: remove empty slice chore: use syscall in x/sys/unix
1 parent a5e0aef commit aee5e5c

File tree

26 files changed

+131
-100
lines changed

26 files changed

+131
-100
lines changed

.github/workflows/pre_check.yaml

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [ pull_request ]
44

55
jobs:
66
compliant:
7-
runs-on: [ self-hosted, X64 ]
7+
runs-on: [ self-hosted, X64, Linux ]
88
steps:
99
- uses: actions/checkout@v3
1010

@@ -16,29 +16,18 @@ jobs:
1616
- name: Check Spell
1717
uses: crate-ci/typos@v1.13.14
1818

19-
staticcheck:
20-
runs-on: [ self-hosted, X64 ]
19+
# 用一个新的、更强大的 linter 作业替换 staticcheck
20+
linter:
21+
runs-on: [ self-hosted, X64, Linux ]
2122
steps:
2223
- uses: actions/checkout@v3
2324
- name: Set up Go
2425
uses: actions/setup-go@v3
2526
with:
26-
go-version: 1.19
27-
28-
- uses: actions/cache@v3
29-
with:
30-
path: ~/go/pkg/mod
31-
key: reviewdog-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
32-
restore-keys: |
33-
reviewdog-${{ runner.os }}-go-
34-
- uses: reviewdog/action-staticcheck@v1
27+
go-version: "1.20"
28+
- name: Run golangci-lint
29+
# 使用官方的 golangci-lint-action
30+
uses: golangci/golangci-lint-action@v8
3531
with:
36-
github_token: ${{ secrets.github_token }}
37-
# Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review].
38-
reporter: github-pr-review
39-
# Report all results.
40-
filter_mode: added
41-
# Exit with 1 when it find at least one finding.
42-
fail_on_error: true
43-
# Set staticcheck flags
44-
staticcheck_flags: -checks=inherit,-SA1029,-SA2002,-SA4006,-SA2002,-SA9003,-S1024 -exclude=example
32+
# 指定要使用的 golangci-lint 版本
33+
version: v2.5

.github/workflows/tests.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,37 @@ jobs:
1010
- name: Set up Go
1111
uses: actions/setup-go@v3
1212
with:
13-
go-version: '1.17'
13+
go-version: '1.20'
1414
- name: Unit Test
1515
run: go test -gcflags=-l -covermode=atomic -coverprofile=coverage.txt
1616
- name: Codecov
1717
run: bash <(curl -s https://codecov.io/bash)
1818

1919
benchmark-test:
20+
needs: unit-scenario-test
2021
runs-on: ubuntu-latest
2122
steps:
2223
- uses: actions/checkout@v3
2324
- name: Set up Go
2425
uses: actions/setup-go@v3
2526
with:
26-
go-version: '1.17'
27+
go-version: '1.20'
2728
- name: Benchmark
2829
run: go test -gcflags='all=-N -l' -bench=. -benchmem -run=none
2930

3031
compatibility-test:
32+
needs: benchmark-test
3133
strategy:
34+
max-parallel: 1
3235
matrix:
33-
go: [1.13, 1.14, 1.15, 1.16, 1.18, 1.19, "1.20" ]
36+
go: [ 1.21, 1.22, 1.23, 1.24, 1.25 ]
3437
os: [ X64 ]
35-
runs-on: ${{ matrix.os }}
38+
runs-on: [ Linux, '${{ matrix.os }}' ]
3639
steps:
3740
- uses: actions/checkout@v3
3841
- name: Set up Go
3942
uses: actions/setup-go@v3
4043
with:
4144
go-version: ${{ matrix.go }}
4245
- name: Unit Test
43-
run: go test -gcflags=-l -covermode=atomic
46+
run: go test -gcflags=-l -covermode=atomic

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.idea
2+
coverage.txt

.golangci.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# .golangci.yml
2+
run:
3+
timeout: 5m
4+
5+
linters:
6+
enable:
7+
- staticcheck
8+
- govet
9+
- ineffassign
10+
- typecheck
11+
exclusions:
12+
paths:
13+
- '(.+)_test\.go'
14+
- 'example'
15+
settings:
16+
staticcheck:
17+
checks:
18+
- all
19+
- '-SA1029'
20+
- '-SA2002'
21+
- '-SA4006'
22+
- '-SA2002'
23+
- '-SA9003'
24+
- '-S1024'
25+
26+
version: '2'

bench_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ package shmipc
1818

1919
import (
2020
"fmt"
21+
syscall "golang.org/x/sys/unix"
2122
"io"
2223
"math/rand"
2324
"net"
2425
"net/http"
2526
_ "net/http/pprof"
2627
"strconv"
27-
"syscall"
2828
"testing"
2929
"time"
3030
)

block_io.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ package shmipc
1818

1919
import (
2020
"fmt"
21+
syscall "golang.org/x/sys/unix"
2122
"io"
22-
"syscall"
2323
)
2424

2525
func blockReadFull(connFd int, data []byte) error {

buffer.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121
"sync"
2222
"sync/atomic"
2323
"unsafe"
24+
25+
"github.com/bytedance/gopkg/lang/dirtmake"
2426
)
2527

2628
var (
@@ -333,7 +335,7 @@ func (l *linkedBuffer) ReadBytes(size int) (result []byte, err error) {
333335
}
334336
// slow path
335337
l.len -= size
336-
result = make([]byte, 0, size)
338+
result = dirtmake.Bytes(0, size)
337339

338340
for size > 0 {
339341
readData, _ := l.sliceList.front().read(size)

buffer_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ package shmipc
1919
import (
2020
"errors"
2121
"fmt"
22+
syscall "golang.org/x/sys/unix"
2223
"os"
2324
"path/filepath"
2425
"sort"
2526
"sync"
2627
"sync/atomic"
27-
"syscall"
2828
"time"
2929
"unsafe"
3030
)

epoll_linux.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !arm64
12
// +build !arm64
23

34
/*
@@ -19,11 +20,12 @@
1920
package shmipc
2021

2122
import (
22-
"syscall"
23+
syscall "golang.org/x/sys/unix"
24+
2325
"unsafe"
2426
)
2527

26-
const epollModeET = -syscall.EPOLLET
28+
const epollModeET = syscall.EPOLLET
2729

2830
type epollEvent struct {
2931
events uint32

epoll_linux_arm64.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package shmipc
1818

1919
import (
20-
"syscall"
20+
syscall "golang.org/x/sys/unix"
2121
"unsafe"
2222
)
2323

0 commit comments

Comments
 (0)