How do I convert a string to a lower case representation?

Go

Go Problem Overview


How do I convert a string to a lower case representation?

I feel that there must be built-in function for it, but I just can't find it.

I did find a ToLower in "unicode/letter", but it only works for one rune at a time.

Go Solutions


Solution 1 - Go

Yes there is, check the strings package.

package main

import (
	"fmt"
	"strings"
)

func main() {
	fmt.Println(strings.ToLower("Gopher"))
}

Solution 2 - Go

If you happen to be too lazy to click through to the strings package, here's example code:

strings.ToLower("Hello, WoRLd") // => "hello, world"

If you need to handle a Unicode Special Case like Azeri or Turkish, you can use ToLowerSpecial:

strings.ToLowerSpecial(unicode.TurkishCase, "Hello, WoRLd") // => "hello, world"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionoersView Question on Stackoverflow
Solution 1 - GoAurAView Answer on Stackoverflow
Solution 2 - GoRyan EndacottView Answer on Stackoverflow