Monday, April 29, 2024
HomeGolangKind of string letter confusion - Getting Assist

Kind of string letter confusion – Getting Assist


Why a single letter in go is a string kind:

myLetter := "S"
fmt.Println(mirror.TypeOf(myLetter))
//
// string

… however letter taken from the string as an desk ingredient is uint8:

myString := "String"
myLetter := myString[0]
fmt.Println(mirror.TypeOf(myLetter))
//
// uint8

… and once I use for-loop its int32 the entire sudden:

myString := "String"
	for _, v := vary myString {
		fmt.Println(mirror.TypeOf(v))
                //
                // int32 (x5)
	}

That is soooo complicated me once I code, plus I want to write down extra changing capabilities at any time when I do one thing string-manipulation-related.

What’s the reasoning behind this? Do you may have any methods to enhance my workflow?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments