Skip to content
This repository has been archived by the owner on Aug 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #8 from vincent99/master
Browse files Browse the repository at this point in the history
Trim zeros off floats better-er
  • Loading branch information
vincent99 committed Jan 12, 2016
2 parents 36cb962 + a32fdfc commit 3fbf8ac
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ func respondText(w http.ResponseWriter, req *http.Request, val interface{}) {
fmt.Fprintf(w, "%d", v)
case float64:
// The default format has extra trailing zeros
str := strings.TrimRight(fmt.Sprintf("%f", v), ".0")
str := strings.TrimRight(fmt.Sprintf("%f", v), "0")
str = strings.TrimRight(str, ".")
fmt.Fprint(w, str)
case bool:
if v {
Expand Down

0 comments on commit 3fbf8ac

Please sign in to comment.