Skip to content

Commit

Permalink
add safecast
Browse files Browse the repository at this point in the history
  • Loading branch information
ldemailly committed Sep 16, 2024
1 parent 9cee76f commit 3fded73
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dnsping.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"fortio.org/cli"
"fortio.org/fortio/stats"
"fortio.org/log"
"fortio.org/safecast"
"github.com/miekg/dns"
)

Expand Down Expand Up @@ -178,9 +179,9 @@ func DNSPing(cfg *DNSPingConfig) *DNSPingResults {
}
switch {
case cfg.FixedID != 0:
m.Id = uint16(cfg.FixedID)
m.Id = safecast.MustConvert[uint16](cfg.FixedID)
case cfg.SequentialIDs:
m.Id = uint16(i) // might wrap but it's fine
m.Id = uint16(i) //nolint:gosec we do want to wrap, it's fine.

Check failure on line 184 in dnsping.go

View workflow job for this annotation

GitHub Actions / call-gochecks / check (ubuntu-latest)

G115: integer overflow conversion int -> uint16 (gosec)
default:
m.Id = dns.Id()
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
fortio.org/cli v1.9.0
fortio.org/fortio v1.66.3
fortio.org/log v1.16.0
fortio.org/safecast v0.1.1
fortio.org/testscript v0.3.2
github.com/miekg/dns v1.1.61
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ fortio.org/fortio v1.66.3 h1:N/Ic9W2tVoJ5LAcr8ZjcF3mNb2ftCw77ZtKF02jwf8Q=
fortio.org/fortio v1.66.3/go.mod h1:+W7ooyLn/Fp3h0UF9JclFEJN50EOvelO6c+VhCYGwnM=
fortio.org/log v1.16.0 h1:GhU8/9NkYZmEIzvTN/DTMedDAStLJraWUUVUA2EbNDc=
fortio.org/log v1.16.0/go.mod h1:t58Spg9njjymvRioh5F6qKGSupEsnMjXLGWIS1i3khE=
fortio.org/safecast v0.1.1 h1:lKSckzBVCbeJXTNUiAvBdplYUafEHM9BahrP46WgPEQ=
fortio.org/safecast v0.1.1/go.mod h1:xZmcPk3vi4kuUFf+tq4SvnlVdwViqf6ZSZl91Jr9Jdg=
fortio.org/struct2env v0.4.1 h1:rJludAMO5eBvpWplWEQNqoVDFZr4RWMQX7RUapgZyc0=
fortio.org/struct2env v0.4.1/go.mod h1:lENUe70UwA1zDUCX+8AsO663QCFqYaprk5lnPhjD410=
fortio.org/testscript v0.3.2 h1:ks5V+Y6H6nmeGqnVlZuLdiFwpqXemDkEnyGgCZa/ZNA=
Expand Down

0 comments on commit 3fded73

Please sign in to comment.