Use decimal.Decimal to represent floats more easily

This commit is contained in:
2025-08-10 14:00:20 +01:00
parent 528540a723
commit ba00980217
19 changed files with 92 additions and 67 deletions
+2 -2
View File
@@ -3,10 +3,10 @@ package pages
import (
"expenses/expenses"
mod "expenses/expenses/models"
"strconv"
"time"
"github.com/gin-gonic/gin"
"github.com/shopspring/decimal"
)
func processFormShares(c *gin.Context) ([]mod.ExpenseShare, error) {
@@ -36,7 +36,7 @@ func expenseFromForm(c *gin.Context) (*mod.Expense, error) {
date := formattedDate.Unix()
newValue := c.PostForm("expense-value")
value, err := strconv.ParseFloat(newValue, 32)
value, err := decimal.NewFromString(newValue)
if err != nil {
return nil, err
}