Menu Close

Go – How to check if Unicode code point or rune is present in string ?

Here, We are going to learn about checking unicode point or rune is present in string.We can check this by using ContainsRune() function of strings package in go golang.

Function prototype:

func ContainsRune(str string, r rune) bool

Return value:

ContainsRune() function returns whether the Unicode code point r is within str as true and false value respectively.


package main

import (

func main() {
	// Finds whether a string contains a particular Unicode code
	// point.
	// The code point for the lowercase letter "a", for example,
	// is 97.
	fmt.Println(strings.ContainsRune("aadlik", 97))
	fmt.Println(strings.ContainsRune("peek", 97))



To learn more about golang, Please refer given below link.

Posted in golang, packages, strings

Leave a Reply

Your email address will not be published. Required fields are marked *