Ad space (banner)
๐ŸนGo Lessons
Lesson 13 / 68

Using the Standard Library

In this lesson you will learn about the handy features in Go's strings package so you know what you do not have to build yourself. This is for anyone searching for "Go strings package how to use".

The strings package gathers handy functions for working with text. strings.ToUpper and strings.Repeat are among the most used.

The sample code converts to upper case with strings.ToUpper("hello"), repeats a character with strings.Repeat("0", 2), and reads the length of a slice with len([]int{1, 2, 3}). Go's standard library is often complete enough that you need no third-party code at all, and simply knowing what is there makes implementation far easier.

A common stumbling block for beginners is not knowing what the standard packages already provide and writing the same logic out at length by hand. Beyond strings there are strconv, math, and many more, organised by purpose, so the habit of looking first pays off.

In real-world development, how well you know the standard library maps directly onto the quality of your code and the speed you write it.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run Go directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)