Published
- 1 min read
golang check rune is number
The solution for this is noted below
golang check rune is number
Solution
// Go program to illustrate how to
// check the given rune is a
// decimal digit or not
package main
import (
"fmt"
"unicode"
)
// Main function
func main() {
// Creating rune
rune_1 := 'g'
rune_2 := 'e'
rune_3 := '1'
rune_4 := '4'
rune_5 := 'S'
// Checking the given rune is
// a decimal digit or not
// Using IsDigit() function
res_1 := unicode.IsDigit(rune_1)
res_2 := unicode.IsDigit(rune_2)
res_3 := unicode.IsDigit(rune_3)
res_4 := unicode.IsDigit(rune_4)
res_5 := unicode.IsDigit(rune_5)
// Displaying results
fmt.Println(res_1)
fmt.Println(res_2)
fmt.Println(res_3)
fmt.Println(res_4)
fmt.Println(res_5)
}
Try other methods by searching on the site. That is if this doesn’t work