On Saturday, November 24, 2012 at 4:21:23 PM UTC+5:30, Nikolai wrote:
>
> Hi!
>
> What is the easiest way to make a string "LikeThis" --> "likeThis"?
>

Here is my answer 

    bytestr := []byte(str)
    for index, character := range bytestr {
        char := string(character)
        if char == strings.ToUpper(char) {
            // Is lowercase
            bytestr[index] = []byte(strings.ToLower(char))[0]
        } else {
            bytestr[index] = []byte(strings.ToUpper(char))[0]
        }
    }

Small hack of converting byte to string. Applying method re-converting to 
byte array. But we know it consists on ly one element. So index 0 will 
return you the modified byte.

Hope it is useful. Ugly but does the job for me.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to