Avatar ·

How to check if a string contains a substring in Go?

Hello! I just started learning Go and encountered a seemingly simple task: I need to check if a string contains a specific substring. In other languages, for example in Python, I would write `if "sub" in "string":`, but such an operator doesn't work in Go. I tried looking in the documentation, but haven't figured it out yet. I need to understand how to correctly and efficiently solve this problem. Here's an example of the code I'm trying to write: ```go package main import "fmt" func main() { str := "Hello, World!" substr := "World" // How to check here that str contains substr? // if str contains substr { // fmt.Println("Substring found!") // } } ``` I know that Go has the `strings` package, but I'm not sure which function from it is suitable. I've seen mentions of `Contains`