In this snippet, we are going to see how we can test if a string contains another string in Go.
To do this we’ll be using the standard library
strings package as it contains an incredibly handy function
Contains which we can pass 2 arguments into. The first argument is our full string, the second is the string we want to check for.
In this example, we have our
originalString which we test to see if it contains the string
We then use the same function to check a negative case and see if
meh exists in the second string.
If you liked this snippet, you make also like some of the other content on this site: