Last active
June 23, 2024 09:05
-
-
Save flaviocopes/6717857ca7ba7266d41330329eeb5ad0 to your computer and use it in GitHub Desktop.
Go: check if a string starts with a substring #golang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"strings" | |
) | |
func main() { | |
strings.HasPrefix("foobar", "foo") // true | |
} |
Thanks
Thanks
hey, newb here: how is this faster/more efficient than say
switch strings.ToUpper(str[:1]) { case "x": .. case "y": .. }
?
Thanks and Regards!
It's not case-insensitive but it does the same, here's the code: https://golang.org/src/strings/strings.go?s=11177:11214#L438
Much obliged! 🙏
Thanks
Thanks
so... how to let regex string match the begining?
thanks!
Thanks!
Thank you!
thank
Merci!
Gracias!
Still going strong in 2022!
Danke
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks