How golang uses the index to get the value in a string

Hello, everyone. I have a question to ask you. I have a string s: = "ts_flow" and then I want to take the first index. I used to use python, just say python is s [1]. But take it out and it"s a number. I want to make the judgment of if s [1] = "" and then do something, but I can"t do it now. One is that s [1] doesn"t come out of s and the other "" says that it needs to be bytes. If I change it to "", I don"t know if it will affect the judgment. So I would like to ask how to smoothly get every character in the string through the index, in addition, it is only the problem of . Thank you

Dec.21,2021

if you want to compare strings, you can use slices to intercept your string s: for example, s [1:2] is s , you can use if s [1:2] = " to judge


string (s [1]) ="


A character in a string in Golang of type rune , which can be compared directly with s [1] = ='s', because both are of type rune. Golang is a strongly typed language that requires consistent comparison of types.

in Golang, more string processing is included in the strings package of Golang. It is recommended to learn the basics of the string type before learning the strings package.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36f2c-2b3ba.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36f2c-2b3ba.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?