Skip to content

Commit

Permalink
Update golang version
Browse files Browse the repository at this point in the history
  • Loading branch information
outdead committed Feb 3, 2024
1 parent 1c73610 commit 485ecc1
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 47 deletions.
65 changes: 32 additions & 33 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,35 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.19.2

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Lint
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.53.3

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0
args: --config=.golangci.yml

# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: false

- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Test
run: go test -v ./...

- name: Build
run: go build -v .
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.21.6

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Lint
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.55.2

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0
args: --config=.golangci.yml

# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: false

- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Test
run: go test -v ./...

- name: Build
run: go build -v .
67 changes: 64 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ run:
skip-dirs:
- vendor/
skip-files:
- .gitignore
- ".*_test.go$"

output:
Expand Down Expand Up @@ -47,6 +46,8 @@ linters-settings:
gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 15
cyclop:
max-complexity: 15
godox:
keywords:
- "BUG"
Expand Down Expand Up @@ -117,15 +118,75 @@ linters-settings:
allow-trailing-comment: true
# Force newlines in end of case at this limit (0 = never).
force-case-trailing-whitespace: 0
varnamelen:
# The longest distance, in source lines, that is being considered a "small scope." (defaults to 5)
# Variables used in at most this many lines will be ignored.
max-distance: 5
# The minimum length of a variable's name that is considered "long." (defaults to 3)
# Variable names that are at least this long will be ignored.
min-name-length: 3
# Check method receivers. (defaults to false)
check-receiver: false
# Check named return values. (defaults to false)
check-return: false
# Check type parameters. (defaults to false)
check-type-param: false
# Ignore "ok" variables that hold the bool return value of a type assertion. (defaults to false)
ignore-type-assert-ok: false
# Ignore "ok" variables that hold the bool return value of a map index. (defaults to false)
ignore-map-index-ok: false
# Ignore "ok" variables that hold the bool return value of a channel receive. (defaults to false)
ignore-chan-recv-ok: false
# Optional list of variable names that should be ignored completely. (defaults to empty list)
ignore-names:
- err
# Optional list of variable declarations that should be ignored completely. (defaults to empty list)
# Entries must be in one of the following forms (see below for examples):
# - for variables, parameters, named return values, method receivers, or type parameters:
# <name> <type> (<type> can also be a pointer/slice/map/chan/...)
# - for constants: const <name>
ignore-decls:
- t testing.T
- f *foo.Bar
- e error
- i int
- n int
- const C
- T any
- m map[string]int
- x int
- y int
- w io.Writer
- r io.Reader
- i int64
- f *os.File
- m int
- n int64
- i int32
- c *Context

linters:
enable-all: true
disable:
- gomnd
- depguard
- interfacer # is deprecated (since v1.38.0)
- scopelint # is deprecated (since v1.39.0)
- golint # is deprecated (since v1.41.0)
- maligned # is deprecated (since v1.38.0)
- ifshort # is deprecated (since v1.48.0)
- deadcode # is deprecated (since v1.49.0)
- nosnakecase # is deprecated (since v1.48.1)
- varcheck # is deprecated (since v1.49.0)
- exhaustivestruct # is deprecated (since v1.46.0)
- structcheck # is deprecated (since v1.49.0)
- rowserrcheck # is disabled because of generics
- sqlclosecheck # is disabled because of generics
- structcheck # is disabled because of generics
- wastedassign # is disabled because of generics
- tagliatelle
- varnamelen
- wrapcheck
- exhaustruct
- depguard

issues:
exclude:
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [v1.1.3] - 2024-02-03
### Updated
- Updated Golang to 1.21.6 version.
- Updated golangci linter to 1.55.2 version.

## [v1.1.2] - 2021-01-06
### Updated
- Updated golangci linter to 1.33 version in CI
Expand Down Expand Up @@ -39,7 +44,8 @@ job was joined with tests workflow.
### Added
- Initial implementation.

[Unreleased]: https://github.com/gorcon/websocket/compare/v1.1.2...HEAD
[Unreleased]: https://github.com/gorcon/websocket/compare/v1.1.3...HEAD
[v1.1.3]: https://github.com/gorcon/websocket/compare/v1.1.2...v1.1.3
[v1.1.2]: https://github.com/gorcon/websocket/compare/v1.1.1...v1.1.2
[v1.1.1]: https://github.com/gorcon/websocket/compare/v1.1.0...v1.1.1
[v1.1.0]: https://github.com/gorcon/websocket/compare/v1.0.1...v1.1.0
Expand Down
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module github.com/gorcon/websocket

go 1.19
go 1.21

require github.com/gorilla/websocket v1.5.0
require github.com/gorilla/websocket v1.5.1

require golang.org/x/net v0.17.0 // indirect
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
9 changes: 7 additions & 2 deletions message.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package websocket

import "math/rand"
import (
"math/rand"
"time"
)

const RandIdentifierLimit = 1000

// Message is both requests and responses are sent as packets wia WebSocket.
// Their payload follows the following basic structure.
Expand Down Expand Up @@ -28,6 +33,6 @@ type Message struct {
func newMessage(command string) *Message {
return &Message{
Message: command,
Identifier: rand.Intn(1000),
Identifier: rand.New(rand.NewSource(time.Now().UnixNano())).Intn(RandIdentifierLimit),
}
}
3 changes: 0 additions & 3 deletions websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"math/rand"
"net"
"net/url"
"time"
Expand Down Expand Up @@ -62,8 +61,6 @@ func Dial(address string, password string, options ...Option) (*Conn, error) {
return nil, fmt.Errorf("webrcon: %w", err)
}

rand.Seed(time.Now().UnixNano())

client := Conn{conn: conn, settings: settings}

return &client, nil
Expand Down
2 changes: 1 addition & 1 deletion websocket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func TestConn_Execute(t *testing.T) {
conn.Close()

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

0 comments on commit 485ecc1

Please sign in to comment.