Skip to content

Commit

Permalink
ds: fix staticcheck warnings (#262)
Browse files Browse the repository at this point in the history
Signed-off-by: Siarhiej Siemianczuk <pdp.eleven11@gmail.com>
  • Loading branch information
binjip978 authored Dec 25, 2023
1 parent bd3546c commit 4284bb8
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions ds/ds.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ type Query struct {

const (
// Default is the default query.
Default = "dnssd://?sort=tenants&sort=cpu.pcnt"
Default = "dnssd://?sort=tenants&sort=cpu.pcnt"
// Timeout is the default query timeout.
Timeout = 1 * time.Second // query-timeout
Timeout = 1 * time.Second // query-timeout
timeFormat = "15:04:05.000"
update = 60 * time.Second // server meta-data refresh
update = 60 * time.Second // server meta-data refresh
)

// client relative code
Expand All @@ -71,15 +71,15 @@ func required(src map[string]string, req map[string][]string) bool {
v("error: poorly formed comparison in requirements")
return false
}
reqval, err := strconv.ParseFloat(req[k][0][1:], 10)
reqval, err := strconv.ParseFloat(req[k][0][1:], 64)
if err != nil {
v("error: non-numeric comparison in requirement")
return false
}
if len(src[k]) == 0 { // key not present, so requirement not met
return false
}
val, err := strconv.ParseFloat(src[k], 10)
val, err := strconv.ParseFloat(src[k], 64)
if err != nil {
v("error: non-numeric comparison in providing meta-data")
return false
Expand Down Expand Up @@ -121,11 +121,11 @@ func Parse(uri string) (Query, error) {

u, err := url.Parse(uri)
if err != nil {
return result, fmt.Errorf("Trouble parsing url %s: %w", uri, err)
return result, fmt.Errorf("trouble parsing url %s: %w", uri, err)
}

if u.Scheme != "dnssd" {
return result, fmt.Errorf("Not an dns-sd URI")
return result, fmt.Errorf("not an dns-sd URI")
}

// following dns-sd URI conventions from CUPS
Expand Down Expand Up @@ -158,7 +158,7 @@ func Parse(uri string) (Query, error) {
break
}
}
if found == false {
if !found {
result.Domain = u.Hostname()
}
}
Expand Down Expand Up @@ -236,12 +236,12 @@ func genSortTxt(key string, operator byte) lessFunc {
return false
}
}
n1, err := strconv.ParseFloat(c1.Text[key], 10)
n1, err := strconv.ParseFloat(c1.Text[key], 64)
if err != nil {
v("Bad format in entry TXT")
return false
}
n2, err := strconv.ParseFloat(c2.Text[key], 10)
n2, err := strconv.ParseFloat(c2.Text[key], 64)
if err != nil {
v("Bad format in entry TXT")
return false
Expand All @@ -262,7 +262,7 @@ func genSortTxt(key string, operator byte) lessFunc {
}
}

//sortentries performs a numeric sort based on a particular key (assumes numeric values)
// sortentries performs a numeric sort based on a particular key (assumes numeric values)
func sortEntries(req map[string][]string, entries []dnssd.BrowseEntry) {
if len(req["sort"]) == 0 {
return
Expand Down

0 comments on commit 4284bb8

Please sign in to comment.