<li><code>sudo gem install rails</code></li> How do I convert a string to a lower case representation?

  • to install jekyll I also needed sudo
  • How do I convert a string to a lower case representation?

  • sudo gem install jekyll bundler
  • I feel that there must be built-in function for it, but I just can't find it.

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

    73430 次浏览

    Yes there is, check the strings package.

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

    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"