Standard library / strings
strings.IndexRune()
Returns the byte offset of the first occurrence of r, or -1; RuneError also matches invalid UTF-8. Expected stdout: '1\n'.
Formal Syntax & Structure
go syntaxgo
func IndexRune(s string, r rune) intParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | string | Input text or sequence. |
| r | rune | Unicode code point. |
Return Value
int
Returns the byte offset of the first occurrence of r, or -1; RuneError also matches invalid UTF-8.
Working Example
Example Snippetgo
package main
import ( "fmt" "strings")
func main() { fmt.Println(strings.IndexRune("aé", 'é'))}