Ad

Convert A Decimal Array To String Format In Golang

- 1 answer

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 
Ad

Answer

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

Ad
source: stackoverflow.com
Ad