[Solved] Append int value to string


You can use strconv from the strconv package

package main

import (
    "fmt"
    "strconv"
)

func main() {
    a := 4 
    b := 3
    c := "1"

    fmt.Println(c + strconv.Itoa(a) + strconv.Itoa(b))
}

Or you can use Sprintf from the fmt package:

package main

import (
    "fmt"
)

func main() {
    a := 4 
    b := 3
    c := "1"
    c = fmt.Sprintf("%s%d%d",c,a,b)

    fmt.Println(c + strconv.Itoa(a) + strconv.Itoa(b))
}

1

solved Append int value to string