Skip to content

Commit c0e5518

Browse files
authored
fix(data): wrong SetData Disable mask (#7)
* fix(data): wrong SetData Disable mask * chore: make lint happy
1 parent 45e9b00 commit c0e5518

4 files changed

Lines changed: 18 additions & 19 deletions

File tree

.github/workflows/pull.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ jobs:
66
runs-on: ubuntu-latest
77
steps:
88
- name: Set up Go
9-
uses: actions/setup-go@v2
9+
uses: actions/setup-go@master
1010
with:
11-
go-version: "1.20"
11+
go-version: "1.24"
1212

1313
- name: Check out code into the Go module directory
14-
uses: actions/checkout@v2
14+
uses: actions/checkout@master
1515

1616
- name: golangci-lint
1717
uses: golangci/golangci-lint-action@master

.github/workflows/push.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ jobs:
66
runs-on: ubuntu-latest
77
steps:
88
- name: Set up Go
9-
uses: actions/setup-go@v2
9+
uses: actions/setup-go@master
1010
with:
11-
go-version: "1.20"
11+
go-version: "1.24"
1212

1313
- name: Check out code into the Go module directory
14-
uses: actions/checkout@v2
14+
uses: actions/checkout@master
1515

1616
- name: golangci-lint
1717
uses: golangci/golangci-lint-action@master
1818
with:
1919
version: latest
20-
args: --issues-exit-code=0
20+
args: --issues-exit-code=0 --timeout=10m
2121
- name: Commit back
2222
continue-on-error: true
2323
run: |

.golangci.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
linters-settings:
22
errcheck:
3-
ignore: fmt:.*
43
ignoretests: true
54

65
goimports:
@@ -18,11 +17,10 @@ linters:
1817
fast: false
1918
enable:
2019
- bodyclose
21-
#- deadcode
2220
#- depguard
2321
- dogsled
2422
- errcheck
25-
- exportloopref
23+
#- exportloopref
2624
- exhaustive
2725
#- funlen
2826
#- goconst
@@ -39,13 +37,11 @@ linters:
3937
- nolintlint
4038
- rowserrcheck
4139
- staticcheck
42-
#- structcheck
4340
- stylecheck
4441
- typecheck
4542
- unconvert
4643
- unparam
4744
- unused
48-
#- varcheck
4945
- whitespace
5046
- prealloc
5147
- predeclared
@@ -57,22 +53,23 @@ linters:
5753
run:
5854
# default concurrency is a available CPU number.
5955
# concurrency: 4 # explicitly omit this value to fully utilize available resources.
60-
deadline: 5m
56+
deadline: 15m
6157
issues-exit-code: 1
6258
tests: false
63-
go: '1.20'
59+
go: '1.24'
6460

6561
# output configuration options
6662
output:
6763
formats:
6864
- format: "colored-line-number"
6965
print-issued-lines: true
7066
print-linter-name: true
71-
uniq-by-line: true
7267

7368
issues:
7469
# Fix found issues (if it's supported by the linter)
7570
fix: true
7671
exclude-use-default: false
72+
uniq-by-line: true
7773
exclude:
78-
- "Error return value of .((os.)?std(out|err)..*|.*Close|.*Seek|.*Flush|os.Remove(All)?|.*print(f|ln)?|os.(Un)?Setenv). is not check"
74+
- "Error return value of .((os.)?std(out|err)..*|.*Close|.*Seek|.*Flush|os.Remove(All)?|.*print(f|ln)?|os.(Un)?Setenv). is not check"
75+
- 'identifier ".*" contain non-ASCII character: U\+.*'

data.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ func (m *Control[CTX]) SetData(groupID int64, data int64) error {
4242
c.Disable = 1
4343
}
4444
}
45+
// c.Disable: Fxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxD
4546
x := bits.RotateLeft64(uint64(c.Disable), 1)
46-
x &= 0x03
47-
x |= uint64(data) << 2
48-
c.Disable = int64(bits.RotateLeft64(x, -1))
47+
// x : xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxDF
48+
x &= 0x02 // mask DF
49+
x |= uint64(data) << 2 // combine with data
50+
c.Disable = int64(bits.RotateLeft64(x, -1)) // rotate back
4951
log.Debugf("[control] set plugin %s of grp %d : 0x%x", m.Service, c.GroupID, data)
5052
m.Manager.Lock()
5153
err = m.Manager.D.Insert(m.Service, &c)

0 commit comments

Comments
 (0)