Standard library / strings

strings.Contains()

Reports whether the literal sequence occurs anywhere, including an empty search sequence. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func Contains(s, substr string) bool

Parameters & Attributes

NameTypeDescription
sstringInput text or sequence.
substrstringSubstring to search for.

Return Value

bool

Reports whether the literal sequence occurs anywhere, including an empty search sequence.

Working Example

Example Snippetgo
package main
import (  "fmt"  "strings")
func main() {  fmt.Println(strings.Contains("café", "fé"))}
Go Reference