package products import ( "math" "strconv" "strings" ) // parseID reads a product ID as the client writes it: "2000000008", or as a float, "2000000008.0" (its JavaScript // numbers go through Python as floats). Every place that takes community products out of what IMVU gets uses it, so a // float can't slip through as "not a product ID". func parseID(s string) (int64, bool) { s = strings.TrimSpace(s) if id, err := strconv.ParseInt(s, 10, 64); err == nil { return id, true } f, err := strconv.ParseFloat(s, 64) if err != nil || f != math.Trunc(f) || math.Abs(f) > 1<<53 { return 0, false } return int64(f), true }