create rune in golang
To create a rune in Go, you can follow the steps below:
Step 1: Import the "fmt" package
import "fmt"
The "fmt" package is used to print the output to the console.
Step 2: Declare a variable of type rune
var myRune rune
This variable will hold the rune value.
Step 3: Assign a value to the variable
myRune = 'A'
Here, we assign the character 'A' to the variable myRune
. The character is enclosed in single quotes to represent a rune value.
Step 4: Print the rune value
fmt.Printf("%c", myRune)
The Printf
function from the "fmt" package is used to print the rune value. The %c
format specifier is used to print the character representation of the rune.
Step 5: Run the program Compile and run the program, and you will see the output as the character 'A' printed on the console.
This is a basic example of how to create and print a rune in Go. Runes are used to represent Unicode characters, and they can be assigned and manipulated just like any other variable in Go.