Welcome To Golang By Example

ASCII digit to the character in Go (Golang)

Table of Contents

Overview

Below is the simple program to convert an ASCII digit to its corresponding character in go. We can simply typecast the number to the string. That will convert it into its corresponding ASCII character

Program

package main

import "fmt"

func main() {
	sampleASCIIDigits := []int{97, 98, 99}
	for _, digit := range sampleASCIIDigits {
		fmt.Printf("Char %s\n", string(digit))
	}
}

Output

Char a
Char b
Char c