Golang strconv.AppendUint() function example

package strconv

Golang strconv.AppendUint() function usage example.

 package main

 import (
  "fmt"
  "strconv"
 )

 func main() {

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

  dst := []byte("Unsigned integer is ")

  fmt.Println("Before : ", string(dst))

  b := strconv.AppendUint(dst, uint64(1), 10) // base 10 for sanity purpose

  fmt.Println("After : ", string(b))

  b = strconv.AppendUint(dst, uint64(99), 10) // base 10 for sanity purpose

  fmt.Println("After : ", string(b))
 }

Output :

Before : Unsigned integer is

After : Unsigned integer is 1

After : Unsigned integer is 99

Reference :

http://golang.org/pkg/strconv/#AppendUint

Advertisement