Use the function Contains from the strings package.

import (
    "strings"
)
strings.Contains("something", "some") // true
Answer from Elliott Beach on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › go language › string-contains-function-in-golang-with-examples
strings.Contains Function in Golang with Examples - GeeksforGeeks
April 28, 2025 - Since strings.Contains() function returns boolean value, it returns true in both the cases. Example 2: Following example illustrates how the user can print the desired result instead of a boolean output: ... // Golang program to illustrate // the strings.Contains() Function package main import ( "fmt" "strings" ) func main() { input := "Golang" str := "This is a Golang program" if strings.Contains(str, input) { fmt.Println("Yes") } }
🌐
Go Packages
pkg.go.dev › strings
strings package - strings - Go Packages
Fields splits the string s around each instance of one or more consecutive white space characters, as defined by unicode.IsSpace, returning a slice of substrings of s or an empty slice if s contains only white space. Every element of the returned slice is non-empty. Unlike Split, leading and trailing runs of white space characters are discarded. ... package main import ( "fmt" "strings" ) func main() { fmt.Printf("Fields are: %q", strings.Fields(" foo bar baz ")) }
🌐
Codecademy
codecademy.com › docs › go › strings › contains()
Go | Strings | Contains() | Codecademy
July 4, 2023 - The Contains() function returns a boolean value indicating whether a given substring is present or not in a given string. The method returns true if the substring is present, otherwise it returns false.
🌐
Hugo
gohugo.io › functions › strings › contains
strings.Contains
April 10, 2025 - Reports whether the given string contains the given substring.
🌐
Dot Net Perls
dotnetperls.com › contains-go
Go - strings.Contains and ContainsAny - Dot Net Perls
Is one string contained in another? With Contains we search one string for a certain substring.
Find elsewhere
🌐
Golangprojectstructure
golangprojectstructure.com › does-one-string-contain-another-in-go
Discovering Whether One String Contains Another in Go | Golang Project Structure
September 30, 2024 - In the example above, the strings.Contains function checks whether the string "Go" exists within the larger string "Welcome to the Go programming language" — which, as we can see from a quick glance at the two strings, it does.
🌐
GoLinuxCloud
golinuxcloud.com › home › programming › golang string contains exposed: pro tips and tricks
Golang String Contains Exposed: PRO Tips and Tricks | GoLinuxCloud
March 20, 2024 - Usage: strings.ContainsRune(s string, r rune) bool · This comes in handy when working with individual Unicode characters in a Golang string. Does it contain rune?
🌐
Codekru
codekru.com › home › strings.contains() method in golang
strings.Contains() method in Golang - Codekru
July 31, 2022 - package main import ( "fmt" "strings" ) func main() { str := "codekru" var result1 bool = strings.Contains(str, "code") var result2 bool = strings.Contains(str, "hello") fmt.Println("Is \"code\" present in \"codekru\"? ", result1) fmt.Println("Is \"hello\" present in \"codekru\"?
🌐
GitHub
github.com › golang › go › issues › 63328
proposal: strings: function to check if a string contains all specified runes · Issue #63328 · golang/go
October 2, 2023 - Use Case Sometimes I encounter scenarios where I need to check if a given string contains all of a specific set of runes, such as vowels ('a', 'e', 'i', 'o', 'u'). Currently, I have to iterate through the string and runes manually. Propo...
Author   hrtsegv
🌐
TutorialKart
tutorialkart.com › golang-tutorial › golang-check-if-string-contains-a-substring
How to check if String contains a Substring in Go?
May 28, 2021 - To check if string contains a substring in Go, call Contains function of strings package and provide the string and substring as arguments to the function.
🌐
IncludeHelp
includehelp.com › golang › strings-contains-function-with-examples.aspx
Golang strings.Contains() Function with Examples
// Golang program to demonstrate the // example of strings.Contains() Function package main import ( "fmt" "strings" ) func main() { var str1 string = "New Delhi, India" var str2 string = "Los Angeles, California" var substr string substr = "Delhi" if strings.Contains(str1, substr) == true { fmt.Printf("\"%s\" contains \"%s\"\n", str1, substr) } else { fmt.Printf("\"%s\" does not contain \"%s\"\n", str1, substr) } if strings.Contains(str2, substr) == true { fmt.Printf("\"%s\" contains \"%s\"\n", str2, substr) } else { fmt.Printf("\"%s\" does not contain \"%s\"\n", str2, substr) } substr = "Cal
🌐
Freshman Tech
freshman.tech › snippets › go › how-to-string-contains-substring
How to check if a string contains a substring in Go
September 1, 2020 - Let’s examine each one in turn: ... // false } The strings.Contains method takes a string as the first argument and reports if the second argument string is present in the first....
🌐
Freshman Tech
freshman.tech › snippets › go › check-if-slice-contains-element
How to Check If a Slice Contains an Element in Go
// https://play.golang.org/p/Q... "Jack")) // false } In the contains() function, each element of the string slice is compared to the specified string (second parameter)....
🌐
TutorialsPoint
tutorialspoint.com › how-to-use-contains-function-in-golang
How to use Contains() function in Golang?
March 10, 2022 - package main // importing fmt and strings import ( "fmt" "strings" ) // using the strings.Contains() function func main() { fmt.Println(strings.Contains("AndhraPradesh", "Pradesh")) fmt.Println(strings.Contains("MadhyaPradesh", "Madhya")) fmt.Println(strings.Contains("CapitalCity", "Delhi")) fmt.Println(strings.Contains("UttarPradesh", "Uttar")) }
🌐
Educative
educative.io › answers › what-is-stringscontainsany-in-go
What is strings.ContainsAny() in Go?
The strings package provides the ContainsAny() method, which can be used to check if the input string contains any of the characters or Unicode code points of another string (passed as another input to the function).
🌐
Programming Idioms
programming-idioms.org › idiom › 133 › case-insensitive-string-contains › 1723 › go
Case-insensitive string contains, in Go
function u_i(string, substr) character (len=*), intent(in) :: string, substr integer :: i,j, c1, c2, u_i u_i = 0 out: do i=1,len(string)-len(substr)+1 c1 = iachar(string(i:i)) if (c1 >= iachar('a') .and. c1 <= iachar('z')) c1 = c1 - 32 do j=0,len(substr)-2 c2 = iachar(substr(j+1:j+1)) if (c2 >= iachar('a') .and. c1 <= iachar('z')) c2 = c2 - 32 if (c1 /= c2) cycle out end do u_i = i return end do out end function u_i ok = u_i(string, word) /= 0 · import Data.Char (toLower) import Data.List (isInfixOf) containsIgnoreCase :: String -> String -> Bool containsIgnoreCase s word = isInfixOf (map toLower word) (map toLower s)