When converting the string "3px" to a float, C is able to handle it but go does not. In go, is there a way to convert the longest valid prefix of a string to a float?
C:
#include <stdlib.h>
#include <stdio.h>
int main() {
printf("%f", atof("3px"));
// result: 3.0
return 0;
}
Go:
package main
import "fmt"
import "strconv"
func main() {
value, err := strconv.ParseFloat("3px", 64)
fmt.Printf("%f, %v
", value, err)
// strconv.ParseFloat: parsing "3px": invalid syntax
}