github.com/gotranspile/cxgo@v0.3.7/runtime/libc/stdlib.go (about) 1 package libc 2 3 import ( 4 "runtime" 5 "strconv" 6 "strings" 7 ) 8 9 func Atoi(s string) int { 10 v, _ := strconv.Atoi(s) 11 return v 12 } 13 14 func Atof(s string) float64 { 15 v, _ := strconv.ParseFloat(s, 64) 16 return v 17 } 18 19 func FuncName() string { 20 pc, _, _, ok := runtime.Caller(1) 21 if !ok { 22 return "<unknown func>" 23 } 24 fnc := runtime.FuncForPC(pc) 25 if fnc == nil { 26 return "<unknown func>" 27 } 28 name := fnc.Name() 29 if i := strings.LastIndex(name, "."); i > 0 { 30 name = name[i+1:] 31 } 32 return name 33 }