Yes there is, check the strings package.
package main
import (
"fmt"
"strings"
)
func main() {
fmt.Println(strings.ToLower("Gopher"))
}
Answer from AurA on Stack OverflowCodecademy
codecademy.com › docs › go › strings › tolower()
Go | Strings | ToLower() | Codecademy
September 5, 2023 - The strings.ToLower() function is a built-in function in Golang that returns a new string with all the characters in the original string converted to lowercase.
Top answer 1 of 2
192
Yes there is, check the strings package.
package main
import (
"fmt"
"strings"
)
func main() {
fmt.Println(strings.ToLower("Gopher"))
}
2 of 2
56
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"
Videos
Go Packages
pkg.go.dev › strings
strings package - strings - Go Packages
Use golang.org/x/text/cases instead. ... package main import ( "fmt" "strings" ) func main() { // Compare this example to the ToTitle example. fmt.Println(strings.Title("her royal highness")) fmt.Println(strings.Title("loud noises")) fmt.Println(strings.Title("брат")) } ... ToLower returns s with all Unicode letters mapped to their lower case.
Zig Quirks
openmymind.net › ASCII_String_To_Lowercase_in_Go
ASCII String to Lowercase in Go
January 19, 2023 - It turns out that strings.ToLower first scans the entire input to determine two things: 1) does the string contain only ASCII characters and 2) does it contain any uppercase characters. Understanding this detail explains all of the performance differences between the two versions.
Codekru
codekru.com › home › strings.tolower() method in golang
strings.ToLower() method in Golang - Codekru
October 24, 2021 - An uninitialized string in Golang is an empty string. So, it will be like passing an empty string in the function and thus we will get the empty string back. package main import ( "fmt" "strings" ) func main() { var string1 string fmt.Println("lowercase string:", strings.ToLower(string1)) }
TutorialsPoint
tutorialspoint.com › how-to-convert-a-string-in-lower-case-in-golang
How to convert a string in lower case in Golang?
April 20, 2023 - The easiest and most common method to convert a string to lowercase in Golang is by using the strings.ToLower() function. This function converts all the ASCII letters in a string to their lowercase equivalents.
GitHub
github.com › golang › go › issues › 17859
strings: optimize ToLower and ToUpper · Issue #17859 · golang/go
November 8, 2016 - According to a profiling data from a large number of servers at Google, strings.ToLower and strings.ToUpper is within the top 300 functions by CPU time. I believe there can be a significant speed-up by specifically handling ASCII charact...
Author dsnet
TutorialKart
tutorialkart.com › golang-tutorial › golang-convert-string-to-lowercase-tolower
How to convert String to Lowercase in Go?
May 26, 2021 - To convert string to lowercase in Go programming, callstrings.ToLower() function and pass the string as argument to this function.
GitHub
github.com › golang › go › issues › 30987
strings: ToLower not returning a copy for strings already in lower case · Issue #30987 · golang/go
March 21, 2019 - This seems to be a result of an optimisation, 13cfb15, and in particular the fully optimized path of lower case ASCII: https://github.com/golang/go/blob/master/src/strings/strings.go#L597 · As string are immutable, it doesn't seem to be a huge issue (except that the documentation is wrong), but as far as I understand this can result in pseudo memory leaks if one relies (as per the documentation) on ToLower to do a copy of small slices of larger strings (and only keeping references to the lower case slice)
Author Feandil
Dot Net Perls
dotnetperls.com › tolower-go
Go - strings.ToLower, ToUpper Examples - Dot Net Perls
We have a string literal with the value of "Name." When we call ToLower, a new string is returned.
GitHub
github.com › golang › go › issues › 64361
strings,bytes: ToLower(), ToUpper() by using bitwise operator · Issue #64361 · golang/go
November 23, 2023 - When the string consists of only ASCII characters, we can convert lower case to upper case using bitwise operators. Bitwise operators are more efficient than using addition or subtraction. go/src/s...
Author ksw2000
TutorialsPoint
tutorialspoint.com › golang-program-to-convert-a-string-into-lowercase
Golang Program to convert a string into lowercase
February 17, 2023 - ToLower() function present in unicode package is used to convert a given string to lowercase.
IncludeHelp
includehelp.com › golang › unicode-tolower-function-with-examples.aspx
Golang unicode.ToLower() Function with Examples
September 18, 2021 - The return type of the unicode.ToLower() function is a rune, it returns the value mapped to lowercase. // Golang program to demonstrate the // example of unicode.ToLower() Function package main import ( "fmt" "unicode" ) func main() { fmt.Printf("%#U\n", unicode.ToLower('Q')) fmt.Printf("%#U\n", ...
Go
go.dev › play › p › fEDCPSV7Dqi
Go Playground - The Go Programming Language
Any requests for content removal should be directed to security@golang.org.
Google Groups
groups.google.com › g › golang-nuts › c › WfpmVDQFecU
How to make the first character in a string lowercase?
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com. ... Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message ... Te easiest is not always the best. The code should be correct and reasonably efficient. For example, func firstToLower(s string) string { if len(s) > 0 { r, size := utf8.DecodeRuneInString(s) if r != utf8.RuneError || size > 1 { lo := unicode.ToLower(r) if lo != r { s = string(lo) + s[size:] } } } return s }
Go Packages
pkg.go.dev › bytes
bytes package - bytes - Go Packages
ToLowerSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their lower case, giving priority to the special casing rules. ... package main import ( "bytes" "fmt" "unicode" ) func main() { str := []byte("AHOJ VÝVOJÁRİ GOLANG") totitle := bytes.ToLowerSpecial(unicode.AzeriCase, str) fmt.Println("Original : " + string(str)) fmt.Println("ToLower : " + string(totitle)) }