The standard library’s strings package provides many useful string-related functions. Here are some examples to give you a sense of the package.
We alias fmt.Println to a shorter name as we’ll use it a lot below.
Here’s a sample of the functions available in strings. Since these are functions from the package, not methods on the string object itself, we need to pass the string in question as the first argument to the function. You can find more functions in the strings package docs.
To run the program, save the code in a file and run it using Node.js.
Now that we can run and understand basic string operations, let’s learn more about the language.