package main

import (
"fmt"
"unicode"
)

func main() {
fmt.Println(MakeFirstLowerCase("LikeThis"))

}

func MakeFirstLowerCase(s string) string {
    if len(s)==0 {
       return s
    }

    r := []rune(s)
    r[0] = unicode.ToLower(r[0])
    return string(r)
}

On Thu, Jun 18, 2020 at 10:38 AM <[email protected]> wrote:

> I think all other solutions works fine, but String Builder struct exists
> for the same reason.
>
> package main
>
> import (
>     "fmt"
>     "strings"
>
> )
>
> func ToLowerCase(str string) string {
>
>     var b strings.Builder
>
>     b.WriteString(strings.ToLower(string(str[0])))
>     b.WriteString(str[1:])
>
>     return b.String()
>
> }
>
> func main() {
>     var str string = "GoLang"
>     fmt.Println(ToLowerCase(str))
> }
>
>
>
> Playground here: https://play.golang.org/p/aAyBGnM5p2x
>
> On Saturday, 24 November 2012 11:51:23 UTC+1, Nikolai wrote:
>>
>> Hi!
>>
>> What is the easiest way to make a string "LikeThis" --> "likeThis"?
>>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/59ede7f8-bfb9-44a0-9fa7-cef1d7288983o%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/59ede7f8-bfb9-44a0-9fa7-cef1d7288983o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAN7WhqjEmDQ7Z%3DuRUzUz0CrdNYUkCnyOdxd4GqazbUB16DmcRw%40mail.gmail.com.

Reply via email to