In this post we look at how to check if a given string starts with something. This is often used in programming and there are different ways to achieve the same goal.
We provide two options in this example. The first is to use the strings package along with the HasPrefix function – this is probably the simplest/best solution. We did include a second option though, if you know how long the prefix that you’re looking for is, you can use the string as a slice and check it’s value.