Skip to content

Commit

Permalink
upgrade to go 1.22 (#68)
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Ding <[email protected]>
  • Loading branch information
jzding authored Jun 14, 2024
1 parent 8c99fc7 commit 19aa966
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 29 deletions.
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
18 changes: 8 additions & 10 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ run:
deadline: 3m
issues-exit-code: 1
tests: true
skip-dirs:
- vendor
- .go

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

Expand All @@ -16,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 @@ -30,13 +29,12 @@ linters:
- goconst
- gocyclo
- goimports
- revive
- gosec
- gosimple
- govet
- ineffassign
- megacheck
- misspell
- revive
- typecheck
- unconvert
- unparam
Expand All @@ -45,6 +43,9 @@ linters:
fast: false

issues:
exclude-dirs:
- vendor
- .git
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- linters:
Expand All @@ -62,6 +63,3 @@ issues:
- linters:
- gosec
text: "G107: Potential HTTP request made with variable url"



4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/redhat-cne/rest-api

go 1.21
go 1.22

require (
github.com/cloudevents/sdk-go/v2 v2.15.2
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.0
github.com/prometheus/client_golang v1.14.0
github.com/redhat-cne/sdk-go v1.0.1-0.20240612145917-11968a1cd0b5
github.com/redhat-cne/sdk-go v1.0.1-0.20240614182056-bfc7566a02ac
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.8.0
golang.org/x/net v0.7.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI
github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc=
github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo=
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
github.com/redhat-cne/sdk-go v1.0.1-0.20240612145917-11968a1cd0b5 h1:QM52C/K6MspPaPBOUId5pMBZxvwDuYOlTqpWcIG4xSI=
github.com/redhat-cne/sdk-go v1.0.1-0.20240612145917-11968a1cd0b5/go.mod h1:KzrDvnkv+1G4iyCyUhbzB168j7q6sD5/e8T3MvlUfYY=
github.com/redhat-cne/sdk-go v1.0.1-0.20240614182056-bfc7566a02ac h1:I9dfgug3GIViEQxgKrLdWB8Y3mqVe0alismyTOdTz6w=
github.com/redhat-cne/sdk-go v1.0.1-0.20240614182056-bfc7566a02ac/go.mod h1:q9LxxPbK1tGpDbQm/KIPujqdP0bK1hhuHrIXV3vuUrM=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
Expand Down
4 changes: 2 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (s *Server) Start() {

api.HandleFunc("/{resourceAddress:.*}/CurrentState", s.getCurrentState).Methods(http.MethodGet)

api.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
api.HandleFunc("/health", func(w http.ResponseWriter, _ *http.Request) {
io.WriteString(w, "OK") //nolint:errcheck
}).Methods(http.MethodGet)

Expand All @@ -290,7 +290,7 @@ func (s *Server) Start() {
// "$ref": "#/responses/badReq"
api.HandleFunc("/create/event", s.publishEvent).Methods(http.MethodPost)

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 {
pathTemplate, err := route.GetPathTemplate()
if err == nil {
log.Println("ROUTE:", pathTemplate)
Expand Down
4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ github.com/prometheus/common/model
github.com/prometheus/procfs
github.com/prometheus/procfs/internal/fs
github.com/prometheus/procfs/internal/util
# github.com/redhat-cne/sdk-go v1.0.1-0.20240612145917-11968a1cd0b5
## explicit; go 1.21
# github.com/redhat-cne/sdk-go v1.0.1-0.20240614182056-bfc7566a02ac
## explicit; go 1.22
github.com/redhat-cne/sdk-go/pkg/channel
github.com/redhat-cne/sdk-go/pkg/event
github.com/redhat-cne/sdk-go/pkg/event/ptp
Expand Down

0 comments on commit 19aa966

Please sign in to comment.