Skip to content

Commit

Permalink
fix fmt float
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelvigee committed Apr 8, 2024
1 parent 105ab70 commit 3cb8b1b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion utils/xstarlark/fmt/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ func (f *formatter) formatExpr(w Writer, expr syntax.Expr) error {
case syntax.INT:
w.WriteString(strconv.FormatInt(expr.Value.(int64), 10))
case syntax.FLOAT:
w.WriteString(strconv.FormatFloat(expr.Value.(float64), 'f', 0, 64))
w.WriteString(strconv.FormatFloat(expr.Value.(float64), 'f', -1, 64))
default:
return fmt.Errorf("unhandled Literal token: %v", expr.Token)
}
Expand Down
3 changes: 3 additions & 0 deletions utils/xstarlark/fmt/testdata/float.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1.5
----
1.5

0 comments on commit 3cb8b1b

Please sign in to comment.