Go Strings Package Part 1

In this blog post, you will learn how to use the ToLower, ToUpper,  and Title functions to change the alphabet case of a string. These functions are part of the Go strings package.

ToLower

You use the ToLower function when you to change the string to lower case. This could be useful for cleaning update before inserting into a database, or before doing other searching operations on the string.

You can run the code here on Go Playground.

ToUpper

You use ToUpper function when you to change the string to upper case. This could be useful for cleaning update before inserting into a database, or before doing other searching operations on the string.

You can run the code here on Go Playground.

Title

You use the Title function when you need to change a string to title case . This function as a small bug that causes it to upper case small words like “the” and “in” so be careful about how you use it. You can find a proper title case example at The Go Cookbook.

You can run the code here on Go Playground.

Conclusion

In this blog post, you learned how to work with the ToLower, ToUpper, and Title functions and when to use them. You can read other blogs on the Go strings package here.

Resources

GitHub Source.

About the Author Harrison Brock

Harrison Brock is a software engineer that focuses on Full Stack web development

follow me on: