Search code examples
stringgodecimalconverters

Convert a decimal array to string format in golang


I want to convert a decimal array to text in string format in golang, is there any function in golang that supports this. Can you give me a sample code? E.g :

97 98 99 
a b c 

Solution

  • package main
    
    import (
        "fmt"
    )
    
    func main() {
        a := []int{97, 98, 99}
        result := []string{}
    
        for _, element := range a {
            result = append(result, string(element))
        }
    
        fmt.Println(result)
    }
    

    [a b c]

    https://go.dev/play/p/WUYIiIcHP16