Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to go 1.22 #93

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,27 @@ jobs:
name: Linting
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v2
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.22'
- name: tidy
run: go mod tidy
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v6
with:
# Caching conflicts happen in GHA, so just disable for now
skip-pkg-cache: true
skip-build-cache: true
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.54
version: v1.59
args: --timeout 3m0s
unit-tests:
name: Unit Tests
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/setup-go@v2
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.22'
- name: tidy
run: go mod tidy
- name: Run Test Scripts
Expand Down
16 changes: 8 additions & 8 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ run:
deadline: 3m
issues-exit-code: 1
tests: true
skip-dirs:
- vendor
- .go
- pkg/util/wait

output:
format: colored-line-number
formats: colored-line-number
print-issued-lines: true
print-linter-name: true

Expand All @@ -18,7 +14,8 @@ linters-settings:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 30
govet:
check-shadowing: true
enable:
- shadow
goconst:
min-len: 3
min-occurrences: 4
Expand All @@ -32,13 +29,12 @@ linters:
- goconst
- gocyclo
- goimports
- revive
- gosec
- gosimple
- govet
- ineffassign
- megacheck
- misspell
- revive
- typecheck
- unconvert
- unparam
Expand All @@ -47,6 +43,10 @@ linters:
fast: false

issues:
exclude-dirs:
- vendor
- .git
- pkg/util/wait
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- linters:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redhat-cne/sdk-go

go 1.21
go 1.22

require (
github.com/cloudevents/sdk-go/v2 v2.15.2
Expand Down
7 changes: 4 additions & 3 deletions pkg/protocol/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,15 @@ func (h *Server) Start(wg *sync.WaitGroup) error {
}
}).Methods(http.MethodGet)

r.HandleFunc("/health", func(w http.ResponseWriter, req *http.Request) {
r.HandleFunc("/health", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
_ = json.NewEncoder(w).Encode(map[string]bool{"ok": true})
})

r.Handle("/event", eventHandler)
r.Handle("/subscription", subscriptionHandler)

err = r.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error {
err = r.Walk(func(route *mux.Route, _ *mux.Router, _ []*mux.Route) error {
var pathTemplate, pathRegexp string
var queriesTemplates, queriesRegexps, methods []string
pathTemplate, err = route.GetPathTemplate()
Expand Down Expand Up @@ -393,7 +393,8 @@ func (h *Server) HTTPProcessor(wg *sync.WaitGroup) {
wg.Add(1)
go func(h *Server, wg *sync.WaitGroup) {
defer wg.Done()
for { //nolint:gosimple Producer: Sender Object--->Event Default Listener:Consumer
// Producer: Sender Object--->Event Default Listener:Consumer
for { //nolint:gosimple
select {
case d := <-h.DataIn: //skips publisher object processing
if d.Type == channel.SUBSCRIBER && (d.Status == channel.NEW || d.Status == channel.DELETE) { // Listener means subscriber aka sender
Expand Down
4 changes: 2 additions & 2 deletions pkg/protocol/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func TestStatusWithSubscription(t *testing.T) {
out := make(chan *channel.DataChan)
eventChannel := make(chan *channel.DataChan, 10)
closeCh := make(chan struct{})
onStatusReceiveOverrideFn := func(e event.Event, d *channel.DataChan) error {
onStatusReceiveOverrideFn := func(_ event.Event, d *channel.DataChan) error {
ce := CloudEvents()
d.Data = &ce
return nil
Expand Down Expand Up @@ -355,7 +355,7 @@ func TestStatusWithOutSubscription(t *testing.T) {
in := make(chan *channel.DataChan)
out := make(chan *channel.DataChan)
closeCh := make(chan struct{})
onStatusReceiveOverrideFn := func(e event.Event, d *channel.DataChan) error {
onStatusReceiveOverrideFn := func(_ event.Event, d *channel.DataChan) error {
ce := CloudEvents()
d.Data = &ce
return nil
Expand Down
6 changes: 3 additions & 3 deletions v1/subscriber/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,17 +251,17 @@ func (p *API) GetSubscriberURLByResource(resource string) (urls []string) {
}

// GetClientIDByResource get subscriptionOne information
func (p *API) GetClientIDByResource(resource string) (clientIds []uuid.UUID) {
func (p *API) GetClientIDByResource(resource string) (clientIDs []uuid.UUID) {
p.SubscriberStore.RLock()
defer p.SubscriberStore.RUnlock()
for _, subs := range p.SubscriberStore.Store {
for _, sub := range subs.SubStore.Store {
if sub.GetResource() == resource {
clientIds = append(clientIds, subs.ClientID)
clientIDs = append(clientIDs, subs.ClientID)
}
}
}
return clientIds
return clientIDs
}

// GetClientIDAddressByResource get subscriptionOne information
Expand Down