I split a string by spaces:
splstr = strings.Split(str, " ")
Then I iterate each word, and look at the first character like this:
splstr[i][0] == "#"
But I got these errors from that line:
... : cannot convert "#" to type uint8
... : invalid operation: splstr[i][0] == "#" (mismatched types uint8 and string)
But then I spliced it:
splstr[i][:1] == "#"
And that works. I get why [:1]
is of type string
, but why is [0]
of type uint8
? (I'm using Go 1.1.)