Skip to content

Commit

Permalink
Update to Go 1.22, update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ewohltman committed Apr 2, 2024
1 parent 5ef815e commit fc23e43
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 64 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/pullRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Go 1.21
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: '1.22'
check-latest: true

- name: Download dependencies
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.55
version: v1.57

- name: Run tests
run: make test
Expand All @@ -39,8 +39,8 @@ jobs:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PATH="${PATH}:$(go env GOPATH)/bin"
GO111MODULE=off go get -u github.com/mattn/goveralls
goveralls -coverprofile=coverage.out -service=github
go install github.com/mattn/goveralls@latest
goveralls -ignore=cmd/* -coverprofile=coverage.out -service=github
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/pullRequestMaster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Go 1.21
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: '1.22'
check-latest: true

- name: Download dependencies
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.55
version: v1.57

- name: Run tests
run: make test
Expand All @@ -39,8 +39,8 @@ jobs:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PATH="${PATH}:$(go env GOPATH)/bin"
GO111MODULE=off go get -u github.com/mattn/goveralls
goveralls -coverprofile=coverage.out -service=github
go install github.com/mattn/goveralls@latest
goveralls -ignore=cmd/* -coverprofile=coverage.out -service=github
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
28 changes: 7 additions & 21 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ linters-settings:
max-complexity: 15
package-average: 0.0
skip-tests: true
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
Expand All @@ -19,30 +17,18 @@ linters-settings:
- opinionated
- performance
- style
disabled-checks:
- hugeParam
- paramTypeCombine
- rangeValCopy
- typeDefFirst
gocyclo:
min-complexity: 15
goimports:
local-prefixes: github.com/ewohltman/ephemeral-roles
golint:
min-confidence: 0.8
govet:
check-shadowing: true
lll:
line-length: 140
maligned:
suggest-new: true
misspell:
locale: US

linters:
enable-all: true
disable:
- contextcheck
- deadcode
- depguard
- exhaustivestruct
Expand All @@ -57,27 +43,26 @@ linters:
- maligned
- nonamedreturns
- nosnakecase
- rowserrcheck
- scopelint
- sqlclosecheck
- structcheck
- tagalign
- tagliatelle
- varcheck
- varnamelen
- wastedassign
- wrapcheck

run:
timeout: 5m
skip-dirs:
- .github
- build
- web

issues:
max-same-issues: 0
exclude-use-default: false
exclude-dirs:
- .github
- build
- web
exclude-files:
- zz_generated.*
exclude-rules:
- path: _test\.go
linters:
Expand All @@ -89,3 +74,4 @@ issues:
- forcetypeassert
- gocyclo
- gosec
- nosnakecase
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module github.com/ewohltman/ephemeral-roles

go 1.21
go 1.22

require (
github.com/bwmarrin/discordgo v0.28.1
github.com/caarlos0/env/v9 v9.0.0
github.com/ewohltman/discordgo-mock v0.0.10
github.com/ewohltman/discordgo-mock v0.0.11
github.com/json-iterator/go v1.1.12
github.com/kz/discordrus v1.3.0
github.com/opentracing/opentracing-go v1.2.0
Expand All @@ -21,7 +21,7 @@ require (
github.com/HdrHistogram/hdrhistogram-go v0.9.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ewohltman/discordgo-mock v0.0.10 h1:ZNOkFzgnODnyEoC0xNrznrG0l8a4hMmNE/XfkBWD2eU=
github.com/ewohltman/discordgo-mock v0.0.10/go.mod h1:fC6zX4gqaQwH/jJZji+K3Fn/ox7EJsG17JJCrJqp61Q=
github.com/ewohltman/discordgo-mock v0.0.11 h1:aRbgVXLFeoSLMCJjO7GyDkXHdMKZh6mVSEKxv73gDyY=
github.com/ewohltman/discordgo-mock v0.0.11/go.mod h1:tu+6ymSz5JKvySUmv7/Q2Oh+aXgxGPir7ZfOz9gfadM=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
Expand Down
24 changes: 12 additions & 12 deletions internal/pkg/callbacks/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestMemberNotFound_Is(t *testing.T) {
t.Error(invalidErrorAssertion)
}

if errors.Is(fmt.Errorf(wrapMsg), &callbacks.MemberNotFoundError{}) {
if errors.Is(errors.New(wrapMsg), &callbacks.MemberNotFoundError{}) {
t.Error(invalidErrorAssertion)
}

Expand All @@ -48,7 +48,7 @@ func TestMemberNotFound_Is(t *testing.T) {
func TestMemberNotFound_Unwrap(t *testing.T) {
t.Parallel()

wrappedErr := fmt.Errorf(wrapMsg)
wrappedErr := errors.New(wrapMsg)

mnf := &callbacks.MemberNotFoundError{Err: wrappedErr}

Expand Down Expand Up @@ -77,7 +77,7 @@ func TestMemberNotFound_Error(t *testing.T) {
)
}

mnf.Err = fmt.Errorf(wrapMsg)
mnf.Err = errors.New(wrapMsg)
expectedErrMsg = fmt.Sprintf("%s: %s", expectedErrMsg, wrapMsg)

if mnf.Error() != expectedErrMsg {
Expand Down Expand Up @@ -139,7 +139,7 @@ func TestChannelNotFound_Is(t *testing.T) {
t.Error(invalidErrorAssertion)
}

if errors.Is(fmt.Errorf(wrapMsg), &callbacks.ChannelNotFoundError{}) {
if errors.Is(errors.New(wrapMsg), &callbacks.ChannelNotFoundError{}) {
t.Error(invalidErrorAssertion)
}

Expand All @@ -151,7 +151,7 @@ func TestChannelNotFound_Is(t *testing.T) {
func TestChannelNotFound_Unwrap(t *testing.T) {
t.Parallel()

wrappedErr := fmt.Errorf(wrapMsg)
wrappedErr := errors.New(wrapMsg)

cnf := &callbacks.ChannelNotFoundError{Err: wrappedErr}

Expand Down Expand Up @@ -180,7 +180,7 @@ func TestChannelNotFound_Error(t *testing.T) {
)
}

cnf.Err = fmt.Errorf(wrapMsg)
cnf.Err = errors.New(wrapMsg)
expectedErrMsg = fmt.Sprintf("%s: %s", expectedErrMsg, wrapMsg)

if cnf.Error() != expectedErrMsg {
Expand Down Expand Up @@ -241,7 +241,7 @@ func TestInsufficientPermission_Is(t *testing.T) {
t.Error(invalidErrorAssertion)
}

if errors.Is(fmt.Errorf(wrapMsg), &callbacks.InsufficientPermissionsError{}) {
if errors.Is(errors.New(wrapMsg), &callbacks.InsufficientPermissionsError{}) {
t.Error(invalidErrorAssertion)
}

Expand Down Expand Up @@ -279,7 +279,7 @@ func TestInsufficientPermission_Error(t *testing.T) {
)
}

inp.Err = fmt.Errorf(wrapMsg)
inp.Err = errors.New(wrapMsg)
expectedErrMsg = fmt.Sprintf("%s: %s", expectedErrMsg, wrapMsg)

if inp.Error() != expectedErrMsg {
Expand Down Expand Up @@ -339,7 +339,7 @@ func TestMaxNumberOfRoles_Is(t *testing.T) {
t.Error(invalidErrorAssertion)
}

if errors.Is(fmt.Errorf(wrapMsg), &callbacks.MaxNumberOfRolesError{}) {
if errors.Is(errors.New(wrapMsg), &callbacks.MaxNumberOfRolesError{}) {
t.Error(invalidErrorAssertion)
}

Expand Down Expand Up @@ -377,7 +377,7 @@ func TestMaxNumberOfRoles_Error(t *testing.T) {
)
}

mnr.Err = fmt.Errorf(wrapMsg)
mnr.Err = errors.New(wrapMsg)
expectedErrMsg = fmt.Sprintf("%s: %s", expectedErrMsg, wrapMsg)

if mnr.Error() != expectedErrMsg {
Expand Down Expand Up @@ -437,7 +437,7 @@ func TestDeadlineExceeded_Is(t *testing.T) {
t.Error(invalidErrorAssertion)
}

if errors.Is(fmt.Errorf(wrapMsg), &callbacks.DeadlineExceededError{}) {
if errors.Is(errors.New(wrapMsg), &callbacks.DeadlineExceededError{}) {
t.Error(invalidErrorAssertion)
}

Expand Down Expand Up @@ -475,7 +475,7 @@ func TestDeadlineExceeded_Error(t *testing.T) {
)
}

mnr.Err = fmt.Errorf(wrapMsg)
mnr.Err = errors.New(wrapMsg)
expectedErrMsg = fmt.Sprintf("%s: %s", expectedErrMsg, wrapMsg)

if mnr.Error() != expectedErrMsg {
Expand Down
2 changes: 0 additions & 2 deletions internal/pkg/callbacks/voiceStatusUpdate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ func TestHandler_VoiceStateUpdate(t *testing.T) {
mutex := &sync.Mutex{}

for _, tc := range testCases {
tc := tc

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
7 changes: 4 additions & 3 deletions internal/pkg/http/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package http_test

import (
"context"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -85,7 +86,7 @@ func doTestRequests(client *http.Client, testServerURL string) error {
}

if resp.Request.Context() == context.Background() {
return fmt.Errorf("request context was not set")
return errors.New("request context was not set")
}

resp, err = doContextRequest(context.Background(), client, testServerURL)
Expand All @@ -99,7 +100,7 @@ func doTestRequests(client *http.Client, testServerURL string) error {
}

if resp.Request.Context() == context.Background() {
return fmt.Errorf("request context was not set")
return errors.New("request context was not set")
}

ctx, cancelCtx := context.WithTimeout(context.Background(), time.Second)
Expand All @@ -116,7 +117,7 @@ func doTestRequests(client *http.Client, testServerURL string) error {
}

if resp.Request.Context() == context.Background() {
return fmt.Errorf("request context was not set")
return errors.New("request context was not set")
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func guildsHandler(log logging.Interface, session *discordgo.Session) http.Handl
}

func rootHandler(log logging.Interface) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
return func(_ http.ResponseWriter, r *http.Request) {
drainCloseRequest(log, r)
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/mock/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func largeGuild(botUser *discordgo.User, role, ephRole *discordgo.Role) *discord

largeGuildMembers := make([]*discordgo.Member, largeGuildSize)

for i := 0; i < largeGuildSize; i++ {
for i := range largeGuildSize {
largeGuildMembers[i] = mockmember.New(
mockmember.WithUser(mockuser.New(
mockuser.WithID(fmt.Sprintf("%s%d", mockconstants.TestUser, i)),
Expand Down
8 changes: 1 addition & 7 deletions internal/pkg/operations/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ func TestGateway_Process(t *testing.T) {
runTestRequestUnknown(t, gateway)

for _, roleName := range roleNames {
roleName := roleName

for i := 0; i < duplicateRequests; i++ {
for range duplicateRequests {
waitGroup.Add(1)

go func() {
Expand Down Expand Up @@ -169,8 +167,6 @@ func TestIsForbiddenResponse(t *testing.T) {
}

for _, testCase := range testCases {
testCase := testCase

t.Run(testCase.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -369,8 +365,6 @@ func runRoleForMemberTestCases(t *testing.T, testCases []*roleForMemberTestCase)
t.Helper()

for _, testCase := range testCases {
testCase := testCase

t.Run(testCase.name, func(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit fc23e43

Please sign in to comment.