github.com/ncruces/go-sqlite3@v0.15.1-0.20240520133447-53eef1510ff0/ext/csv/arg.go (about) 1 package csv 2 3 import ( 4 "fmt" 5 "strconv" 6 7 "github.com/ncruces/go-sqlite3/internal/util" 8 "github.com/ncruces/go-sqlite3/util/vtabutil" 9 ) 10 11 func uintArg(key, val string) (int, error) { 12 i, err := strconv.ParseUint(val, 10, 15) 13 if err != nil { 14 return 0, fmt.Errorf("csv: invalid %q parameter: %s", key, val) 15 } 16 return int(i), nil 17 } 18 19 func boolArg(key, val string) (bool, error) { 20 if val == "" { 21 return true, nil 22 } 23 b, ok := util.ParseBool(val) 24 if ok { 25 return b, nil 26 } 27 return false, fmt.Errorf("csv: invalid %q parameter: %s", key, val) 28 } 29 30 func runeArg(key, val string) (rune, error) { 31 r, _, tail, err := strconv.UnquoteChar(vtabutil.Unquote(val), 0) 32 if tail != "" || err != nil { 33 return 0, fmt.Errorf("csv: invalid %q parameter: %s", key, val) 34 } 35 return r, nil 36 }