Home > other >  Convert a decimal array to string format in golang
Convert a decimal array to string format in golang

Time:03-17

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 

CodePudding user response:

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

  • Related