-
-
Notifications
You must be signed in to change notification settings - Fork 803
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inf values causing marshal error (#1607)
- Loading branch information
1 parent
c7d2ddc
commit 8a7577c
Showing
3 changed files
with
15 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
package api | ||
|
||
import "math" | ||
|
||
// An enum https://golang.org/ref/spec#Iota | ||
const ( | ||
create = iota // 0 | ||
update = iota // 1 | ||
) | ||
|
||
// #1572 - Inf and NaN values cause the JSON marshaller to fail | ||
// Return nil for these values | ||
func handleFloat64(v float64) *float64 { | ||
if math.IsInf(v, 0) || math.IsNaN(v) { | ||
return nil | ||
} | ||
|
||
return &v | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters