Skip to content

Commit 485ecc1

Browse files
committed
Update golang version
1 parent 1c73610 commit 485ecc1

File tree

8 files changed

+119
-47
lines changed

8 files changed

+119
-47
lines changed

.github/workflows/build.yml

+32-33
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,35 @@ jobs:
1515
name: Build
1616
runs-on: ubuntu-latest
1717
steps:
18-
- name: Set up Go 1.x
19-
uses: actions/setup-go@v2
20-
with:
21-
go-version: 1.19.2
22-
23-
- name: Check out code into the Go module directory
24-
uses: actions/checkout@v2
25-
26-
- name: Lint
27-
uses: golangci/golangci-lint-action@v2
28-
with:
29-
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
30-
version: v1.53.3
31-
32-
# Optional: working directory, useful for monorepos
33-
# working-directory: somedir
34-
35-
# Optional: golangci-lint command line arguments.
36-
# args: --issues-exit-code=0
37-
args: --config=.golangci.yml
38-
39-
# Optional: show only new issues if it's a pull request. The default value is `false`.
40-
only-new-issues: false
41-
42-
- name: Get dependencies
43-
run: |
44-
go get -v -t -d ./...
45-
46-
- name: Test
47-
run: go test -v ./...
48-
49-
- name: Build
50-
run: go build -v .
18+
- name: Set up Go 1.x
19+
uses: actions/setup-go@v2
20+
with:
21+
go-version: 1.21.6
22+
23+
- name: Check out code into the Go module directory
24+
uses: actions/checkout@v2
25+
26+
- name: Lint
27+
uses: golangci/golangci-lint-action@v2
28+
with:
29+
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
30+
version: v1.55.2
31+
32+
# Optional: working directory, useful for monorepos
33+
# working-directory: somedir
34+
35+
# Optional: golangci-lint command line arguments.
36+
# args: --issues-exit-code=0
37+
args: --config=.golangci.yml
38+
39+
# Optional: show only new issues if it's a pull request. The default value is `false`.
40+
only-new-issues: false
41+
42+
- name: Get dependencies
43+
run: |
44+
go get -v -t -d ./...
45+
- name: Test
46+
run: go test -v ./...
47+
48+
- name: Build
49+
run: go build -v .

.golangci.yml

+64-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ run:
22
skip-dirs:
33
- vendor/
44
skip-files:
5-
- .gitignore
65
- ".*_test.go$"
76

87
output:
@@ -47,6 +46,8 @@ linters-settings:
4746
gocyclo:
4847
# minimal code complexity to report, 30 by default (but we recommend 10-20)
4948
min-complexity: 15
49+
cyclop:
50+
max-complexity: 15
5051
godox:
5152
keywords:
5253
- "BUG"
@@ -117,15 +118,75 @@ linters-settings:
117118
allow-trailing-comment: true
118119
# Force newlines in end of case at this limit (0 = never).
119120
force-case-trailing-whitespace: 0
121+
varnamelen:
122+
# The longest distance, in source lines, that is being considered a "small scope." (defaults to 5)
123+
# Variables used in at most this many lines will be ignored.
124+
max-distance: 5
125+
# The minimum length of a variable's name that is considered "long." (defaults to 3)
126+
# Variable names that are at least this long will be ignored.
127+
min-name-length: 3
128+
# Check method receivers. (defaults to false)
129+
check-receiver: false
130+
# Check named return values. (defaults to false)
131+
check-return: false
132+
# Check type parameters. (defaults to false)
133+
check-type-param: false
134+
# Ignore "ok" variables that hold the bool return value of a type assertion. (defaults to false)
135+
ignore-type-assert-ok: false
136+
# Ignore "ok" variables that hold the bool return value of a map index. (defaults to false)
137+
ignore-map-index-ok: false
138+
# Ignore "ok" variables that hold the bool return value of a channel receive. (defaults to false)
139+
ignore-chan-recv-ok: false
140+
# Optional list of variable names that should be ignored completely. (defaults to empty list)
141+
ignore-names:
142+
- err
143+
# Optional list of variable declarations that should be ignored completely. (defaults to empty list)
144+
# Entries must be in one of the following forms (see below for examples):
145+
# - for variables, parameters, named return values, method receivers, or type parameters:
146+
# <name> <type> (<type> can also be a pointer/slice/map/chan/...)
147+
# - for constants: const <name>
148+
ignore-decls:
149+
- t testing.T
150+
- f *foo.Bar
151+
- e error
152+
- i int
153+
- n int
154+
- const C
155+
- T any
156+
- m map[string]int
157+
- x int
158+
- y int
159+
- w io.Writer
160+
- r io.Reader
161+
- i int64
162+
- f *os.File
163+
- m int
164+
- n int64
165+
- i int32
166+
- c *Context
120167

121168
linters:
122169
enable-all: true
123170
disable:
124-
- gomnd
125-
- depguard
171+
- interfacer # is deprecated (since v1.38.0)
172+
- scopelint # is deprecated (since v1.39.0)
173+
- golint # is deprecated (since v1.41.0)
174+
- maligned # is deprecated (since v1.38.0)
175+
- ifshort # is deprecated (since v1.48.0)
176+
- deadcode # is deprecated (since v1.49.0)
177+
- nosnakecase # is deprecated (since v1.48.1)
178+
- varcheck # is deprecated (since v1.49.0)
179+
- exhaustivestruct # is deprecated (since v1.46.0)
180+
- structcheck # is deprecated (since v1.49.0)
181+
- rowserrcheck # is disabled because of generics
182+
- sqlclosecheck # is disabled because of generics
183+
- structcheck # is disabled because of generics
184+
- wastedassign # is disabled because of generics
126185
- tagliatelle
127186
- varnamelen
128187
- wrapcheck
188+
- exhaustruct
189+
- depguard
129190

130191
issues:
131192
exclude:

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55

66
## [Unreleased]
77

8+
## [v1.1.3] - 2024-02-03
9+
### Updated
10+
- Updated Golang to 1.21.6 version.
11+
- Updated golangci linter to 1.55.2 version.
12+
813
## [v1.1.2] - 2021-01-06
914
### Updated
1015
- Updated golangci linter to 1.33 version in CI
@@ -39,7 +44,8 @@ job was joined with tests workflow.
3944
### Added
4045
- Initial implementation.
4146

42-
[Unreleased]: https://github.com/gorcon/websocket/compare/v1.1.2...HEAD
47+
[Unreleased]: https://github.com/gorcon/websocket/compare/v1.1.3...HEAD
48+
[v1.1.3]: https://github.com/gorcon/websocket/compare/v1.1.2...v1.1.3
4349
[v1.1.2]: https://github.com/gorcon/websocket/compare/v1.1.1...v1.1.2
4450
[v1.1.1]: https://github.com/gorcon/websocket/compare/v1.1.0...v1.1.1
4551
[v1.1.0]: https://github.com/gorcon/websocket/compare/v1.0.1...v1.1.0

go.mod

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module github.com/gorcon/websocket
22

3-
go 1.19
3+
go 1.21
44

5-
require github.com/gorilla/websocket v1.5.0
5+
require github.com/gorilla/websocket v1.5.1
6+
7+
require golang.org/x/net v0.17.0 // indirect

go.sum

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
2-
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
1+
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
2+
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
3+
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
4+
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=

message.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package websocket
22

3-
import "math/rand"
3+
import (
4+
"math/rand"
5+
"time"
6+
)
7+
8+
const RandIdentifierLimit = 1000
49

510
// Message is both requests and responses are sent as packets wia WebSocket.
611
// Their payload follows the following basic structure.
@@ -28,6 +33,6 @@ type Message struct {
2833
func newMessage(command string) *Message {
2934
return &Message{
3035
Message: command,
31-
Identifier: rand.Intn(1000),
36+
Identifier: rand.New(rand.NewSource(time.Now().UnixNano())).Intn(RandIdentifierLimit),
3237
}
3338
}

websocket.go

-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"encoding/json"
55
"errors"
66
"fmt"
7-
"math/rand"
87
"net"
98
"net/url"
109
"time"
@@ -62,8 +61,6 @@ func Dial(address string, password string, options ...Option) (*Conn, error) {
6261
return nil, fmt.Errorf("webrcon: %w", err)
6362
}
6463

65-
rand.Seed(time.Now().UnixNano())
66-
6764
client := Conn{conn: conn, settings: settings}
6865

6966
return &client, nil

websocket_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func TestConn_Execute(t *testing.T) {
167167
conn.Close()
168168

169169
result, err := conn.Execute("status")
170-
wantErrMsg := fmt.Sprintf("webrcon: write tcp %s->%s: use of closed network connection", conn.LocalAddr(), conn.RemoteAddr())
170+
wantErrMsg := fmt.Sprintf("webrcon: set tcp %s: use of closed network connection", conn.LocalAddr())
171171
if err == nil || err.Error() != wantErrMsg {
172172
t.Errorf("got err %q, want to contain %q", err, wantErrMsg)
173173
}

0 commit comments

Comments
 (0)