Skip to content

Commit

Permalink
Update conerted text to remove trailing 0's with sprintf
Browse files Browse the repository at this point in the history
  • Loading branch information
meabed committed Sep 30, 2018
1 parent 94a4c12 commit c01d35d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/server/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ var ConvertPost = func(w http.ResponseWriter, r *http.Request) {
convertRes.OriginalAmount = convertReq.Amount

// formatted message like "1 USD is worth 3.675 AED"
convertRes.ConvertedText = fmt.Sprintf("%f %s is worth %f %s", convertRes.OriginalAmount, convertRes.From, convertRes.ConvertedAmount, convertRes.To)
convertRes.ConvertedText = fmt.Sprintf("%g %s is worth %g %s", convertRes.OriginalAmount, convertRes.From, convertRes.ConvertedAmount, convertRes.To)

currencyJsonVal, err := json.Marshal(convertRes)
if err != nil {
Expand Down

0 comments on commit c01d35d

Please sign in to comment.