Around to 2 days ago I was trying to make a character randomize. But I
couldn't get char variable, so this led to an
5 hours search for something this I'm was sure it existed. 4 hours later
I remembered that go dose not use ASCII char but it uses this uft8 char.
But any how I started using string after some more research I figer out
that string in Go is a array of runes not chars.
Now the questions is that is it a good idea to use string as a substitute
or is there a better way?
here is the code I was working on
func randChar() string {
op := rand.Intn(3)
var ans int
switch op{
case 0:
ans = '0' + rand.Intn(10) //integers
case 1:
ans = 'A' + rand.Intn(26) //uppercase
case 2:
ans = 'a' + rand.Intn(26) //lowercase
}
return string (ans)
}
//Bardia Jedi
--