[Go] Check whether a string contains a substring

Created on November 30, 2026

Use strings.Contains to check whether the first string contains the second. It returns true on a match and false otherwise.

package main

import (
    "fmt"
    "strings"
)

func main() {
    fmt.Print(strings.Contains("Hello, world", "world"))
}
true

Reference

Go