Skip to content

Commit

Permalink
fix uint overflow conversion CI error
Browse files Browse the repository at this point in the history
  • Loading branch information
0pcom committed Oct 19, 2024
1 parent d442beb commit e842123
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.22.0
toolchain go1.23.1

require (
github.com/chen3feng/safecast v0.0.0-20220908170618-81b2ecd47937
github.com/go-chi/chi v4.1.2+incompatible
github.com/go-chi/cors v1.2.1
github.com/go-redis/redis v6.15.9+incompatible
Expand All @@ -26,7 +27,6 @@ require (
github.com/VictoriaMetrics/metrics v1.35.1 // indirect
github.com/ccding/go-stun/stun v0.0.0-20200514191101-4dc67bcdb029 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chen3feng/safecast v0.0.0-20220908170618-81b2ecd47937 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fatih/color v1.17.0 // indirect
Expand Down
8 changes: 7 additions & 1 deletion pkg/service-discovery/store/postgres_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"sync"

"github.com/chen3feng/safecast"
"github.com/lib/pq"
"github.com/sirupsen/logrus"
"github.com/skycoin/skywire-utilities/pkg/geo"
Expand Down Expand Up @@ -123,7 +124,12 @@ func (s *postgresStore) CountServiceTypes(_ context.Context) (uint64, error) {
return uint64(0), fmt.Errorf("Postgres command returned unexpected error: %w", err)
}

return uint64(countTypes), nil
u, ok := safecast.To[uint64](countTypes)
if ok {
return u, nil
}
return uint64(0), fmt.Errorf("uint64 conversion overflow")

}

func (s *postgresStore) CountServices(ctx context.Context, serviceType string) (uint64, error) {
Expand Down

0 comments on commit e842123

Please sign in to comment.