Skip to content

Commit

Permalink
Upgrade golang to 1.19, upgrade linter to 1.50
Browse files Browse the repository at this point in the history
  • Loading branch information
outdead committed Nov 12, 2022
1 parent e74866a commit 9f916e6
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16
go-version: 1.19.2

- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand All @@ -27,7 +27,7 @@ jobs:
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.42.1
version: v1.50.1

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
60 changes: 60 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,70 @@ 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
- 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:
- 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
- dupword
- gomnd
- wrapcheck

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/gorcon/rcon

go 1.15
go 1.19
7 changes: 5 additions & 2 deletions packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (packet *Packet) Body() string {
}

// WriteTo implements io.WriterTo for write a packet to w.
func (packet *Packet) WriteTo(w io.Writer) (n int64, err error) {
func (packet *Packet) WriteTo(w io.Writer) (int64, error) {
buffer := bytes.NewBuffer(make([]byte, 0, packet.Size+4))

_ = binary.Write(buffer, binary.LittleEndian, packet.Size)
Expand All @@ -90,7 +90,9 @@ func (packet *Packet) WriteTo(w io.Writer) (n int64, err error) {
}

// ReadFrom implements io.ReaderFrom for read a packet from r.
func (packet *Packet) ReadFrom(r io.Reader) (n int64, err error) {
func (packet *Packet) ReadFrom(r io.Reader) (int64, error) {
var n int64

if err := binary.Read(r, binary.LittleEndian, &packet.Size); err != nil {
return n, fmt.Errorf("rcon: read packet size: %w", err)
}
Expand Down Expand Up @@ -120,6 +122,7 @@ func (packet *Packet) ReadFrom(r io.Reader) (n int64, err error) {
var i int32
for i < packet.Size-PacketHeaderSize {
var m int
var err error

if m, err = r.Read(packet.body[i:]); err != nil {
return n + int64(m) + int64(i), fmt.Errorf("rcon: %w", err)
Expand Down

0 comments on commit 9f916e6

Please sign in to comment.