I am trying to check if a given character is present in a byte:
//readBuf: []byte
//n: int
for i:=0;i<n;i++{
if readBuf[i]=="?"{
return true
}
}
"?" is of type string, so I am getting an error, since readBuf[i] is a byte. How can I convert "?" to a byte to be able to compare it to readBuf[i]?
It seems that []byte("?")[0] is working (convert the 1-element string to 1-element byte array, the extract the first value), but I am sure this is not the correct way of doing it.