Skip to content
Closed
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
10 changes: 5 additions & 5 deletions params.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ func (p Params) AddNonEmpty(key, value string) {

// AddNonZero adds a value if it is not zero.
func (p Params) AddNonZero(key string, value int) {
if value != 0 {
if value {
p[key] = strconv.Itoa(value)
}
}

// AddNonZero64 is the same as AddNonZero except uses an int64.
func (p Params) AddNonZero64(key string, value int64) {
if value != 0 {
if value {
p[key] = strconv.FormatInt(value, 10)
}
}
Expand All @@ -39,7 +39,7 @@ func (p Params) AddBool(key string, value bool) {

// AddNonZeroFloat adds a floating point value that is not zero.
func (p Params) AddNonZeroFloat(key string, value float64) {
if value != 0 {
if value {
p[key] = strconv.FormatFloat(value, 'f', 6, 64)
}
}
Expand Down Expand Up @@ -67,12 +67,12 @@ func (p Params) AddFirstValid(key string, args ...interface{}) error {
for _, arg := range args {
switch v := arg.(type) {
case int:
if v != 0 {
if v {
p[key] = strconv.Itoa(v)
return nil
}
case int64:
if v != 0 {
if v {
p[key] = strconv.FormatInt(v, 10)
return nil
}
Expand Down