23 September 2017

Table of Contents

Constants

const IntSize = intSize

Variables

var ErrRange = errors.New("value out of range")
var ErrSyntax = errors.New("invalid syntax")

function

func AppendBool(dst []byte, b bool) []byte

b := []byte("bool:")
b = strconv.AppendBool(b, true)
fmt.Println(string(b))
fmt.Printf("%v\n", b)                   // [98 111 111 108 58 116 114 117 101]
fmt.Printf("%v\n", []byte("bool:true")) // [98 111 111 108 58 116 114 117 101]

func AppendFloat(dst []byte, f float64, fmt byte, prec, bitSize int) []byte

b32 := []byte("float32:")
b32 = strconv.AppendFloat(b32, 3.1415926535, 'E', -1, 32)
fmt.Println(string(b32))        // float32:3.1415927E+00

b64 := []byte("float64:")
b64 = strconv.AppendFloat(b64, 3.1415926535, 'E', -1, 64)
fmt.Println(string(b64))        // float64:3.1415926535E+00

func AppendInt(dst []byte, i int64, base int) []byte

b10 := []byte("int (base 10):")
b10 = strconv.AppendInt(b10, -42, 10)
fmt.Println(string(b10))

b16 := []byte("int (base 16):")
b16 = strconv.AppendInt(b16, -42, 16)
fmt.Println(string(b16))

func AppendQuote(dst []byte, s string) []byte

b := []byte("quote:")
b = strconv.AppendQuote(b, `"Fran & Freddie's Diner"`)
fmt.Println(string(b)) // quote:"\"Fran & Freddie's Diner\""

func AppendQuoteRune(dst []byte, r rune) []byte

b := []byte("rune:")
b = strconv.AppendQuoteRune(b, '☺')
fmt.Println(string(b)) // rune:'☺'

func AppendQuoteRuneToASCII(dst []byte, r rune) []byte

b := []byte("rune (ascii):")
b = strconv.AppendQuoteRuneToASCII(b, '☺')
fmt.Println(string(b)) // rune (ascii):'\u263a'

func AppendQuoteRuneToGraphic(dst []byte, r rune) []byte

func AppendQuoteToASCII(dst []byte, s string) []byte

b := []byte("quote (ascii):")
b = strconv.AppendQuoteToASCII(b, `"Fran & Freddie's Diner"`)
fmt.Println(string(b)) // quote (ascii):"\"Fran & Freddie's Diner\""

func AppendQuoteToGraphic(dst []byte, s string) []byte

func AppendUint(dst []byte, i uint64, base int) []byte

b10 := []byte("uint (base 10):")
b10 = strconv.AppendUint(b10, 42, 10)
fmt.Println(string(b10))

b16 := []byte("uint (base 16):")
b16 = strconv.AppendUint(b16, 42, 16)
fmt.Println(string(b16))

func Atoi(s string) (int, error)

num, _ := strconv.Atoi("10");

func CanBackquote(s string) bool

返回该字符串是否能被 ` 包含

s := `can't backquote this`

fmt.Println(strconv.CanBackquote("Fran & Freddie's Diner ☺")) // true
fmt.Println(strconv.CanBackquote("`can't backquote this`"))   // false
fmt.Println(strconv.CanBackquote(s))                          // true

func FormatBool(b bool) string

v := true
s := strconv.FormatBool(v)
fmt.Printf("%v\n", []byte("true")) // [116 114 117 101]
fmt.Printf("%v\n", []byte(s))      // [116 114 117 101]

func FormatFloat(f float64, fmt byte, prec, bitSize int) string

func FormatInt(i int64, base int) string

func FormatUint(i uint64, base int) string

func IsGraphic(r rune) bool

func IsPrint(r rune) bool

func Itoa(i int) string

func ParseBool(str string) (bool, error)

b1, _ := strconv.ParseBool("true")
fmt.Printf("%v\n", b1) // true

b2, _ := strconv.ParseBool("false")
fmt.Printf("%v\n", b2) // false

b3, _ := strconv.ParseBool("tru")
fmt.Printf("%v\n", b3) // false

b4, _ := strconv.ParseBool("1")
fmt.Printf("%v\n", b4) // true

b5, _ := strconv.ParseBool("0")
fmt.Printf("%v\n", b5) // false

b6, _ := strconv.ParseBool("001")
fmt.Printf("%v\n", b6) // false

func ParseFloat(s string, bitSize int) (float64, error)

v := "3.1415926535"
s1, _ := strconv.ParseFloat(v, 32)
fmt.Printf("%T, %v\n", s1, s1)

s2, _ := strconv.ParseFloat(v, 64) // float64, 3.1415927410125732
fmt.Printf("%T, %v\n", s2, s2)     // float64, 3.1415926535

func ParseInt(s string, base int, bitSize int) (i int64, err error)

v32 := "-354634382"
s1, _ := strconv.ParseInt(v32, 10, 32)
fmt.Printf("%T, %v\n", s1, s1)  // int64, -354634382

s2, _ := strconv.ParseInt(v32, 16, 32)
fmt.Printf("%T, %v\n", s2, s2)  // int64, -2147483648

v64 := "-3546343826724305832"
s3, _ := strconv.ParseInt(v64, 10, 64)
fmt.Printf("%T, %v\n", s3, s3)  // int64, -3546343826724305832

s4, _ := strconv.ParseInt(v64, 16, 64)
fmt.Printf("%T, %v\n", s4, s4)  // int64, -9223372036854775808

func ParseUint(s string, base int, bitSize int) (uint64, error)

v := "42"

s1, _ := strconv.ParseUint(v, 10, 32)
fmt.Printf("%T, %v\n", s1, s1)

s2, _ := strconv.ParseUint(v, 10, 64)
fmt.Printf("%T, %v\n", s2, s2)

func Quote(s string) string

func QuoteRune(r rune) string

func QuoteRuneToASCII(r rune) string

func QuoteRuneToGraphic(r rune) string

func QuoteToASCII(s string) string

func QuoteToGraphic(s string) string

func Unquote(s string) (string, error)

func UnquoteChar(s string, quote byte) (value rune, multibyte bool, tail string, err error)

type NumError

func (e *NumError) Error() string