]> saetta.ns0.it Git - zakegg_go/commitdiff
ParseInt da errore se la stringa รจ un float corretto.
authorAndrea Zagli <azagli@libero.it>
Tue, 30 Aug 2022 12:46:25 +0000 (14:46 +0200)
committerAndrea Zagli <azagli@libero.it>
Tue, 30 Aug 2022 12:46:25 +0000 (14:46 +0200)
form.go

diff --git a/form.go b/form.go
index 0e65e6ada401aa993694e3a98fa746362534679c..de746a8426999181e069d7651c98a782dbb6cb02 100644 (file)
--- a/form.go
+++ b/form.go
@@ -231,12 +231,9 @@ func CreaMapDb (elems map[string]*FormElement) (map[string]interface{}) {
                                /* tolgo la formattazione */
                                str := strings.ReplaceAll(elem.Value, ".", "")
                                str = strings.ReplaceAll(str, ",", ".")
-                               if elem.DBType == "float" || strings.Contains(elem.Validation, "numeric_it=float") {
-                                       v, _ := strconv.ParseFloat(str, 64)
-                                       campi[elem.DBName] = v
-                               } else {
-                                       v, _ := strconv.ParseInt(str, 10, 0)
-                                       campi[elem.DBName] = v
+                               v, _ := strconv.ParseFloat(str, 64)
+                               if elem.DBType == "int" || strings.Contains(elem.Validation, "numeric_it=int") {
+                                       campi[elem.DBName] = int(v)
                                }
                        } else if strings.Contains(elem.Validation, "mydate") {
                                /* metto la data in formato sql */