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") } }
People also ask

Is strings.Contains case-sensitive?
Yes. Normalize with ToLower or ToUpper on both sides for a simple ASCII-heavy case-insensitive contains, or use EqualFold when comparing whole strings.
🌐
golinuxcloud.com
golinuxcloud.com › home › programming › check if a string contains a substring in go (strings.contains)
Go strings.Contains, substring, case insensitive, ContainsAny
🌐
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.
🌐
GoLinuxCloud
golinuxcloud.com › home › programming › check if a string contains a substring in go (strings.contains)
Go strings.Contains, substring, case insensitive, ContainsAny
September 29, 2023 - strings.Contains for literal UTF-8 substrings, case sensitivity and ToLower, match any or all needles, ContainsAny and ContainsRune, Index and HasPrefix or HasSuffix, empty substring behavior, and regexp only when you need patterns.
Find elsewhere
🌐
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....
🌐
TutorialsPoint
tutorialspoint.com › how-to-use-contains-function-in-golang
How to use Contains() function in Golang?
March 10, 2022 - Golang has a set of built-in string ... of operations on string data. Contains() is such a function that can be used to search whether a particular text/string/character is present in a given string....
🌐
GeeksforGeeks
geeksforgeeks.org › go language › check-if-the-given-characters-is-present-in-golang-string
Check if the given characters is present in Golang String - GeeksforGeeks
July 12, 2025 - If the letter is present in the given string, then it will return true, otherwise, return false. Syntax: func Contains(str, chstr string) bool Here, str is the original string and chstr is the string which you wants to check.
🌐
Hugo
gohugo.io › functions › strings › contains
strings.Contains
April 10, 2025 - Reports whether the given string contains the given substring.
🌐
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.
🌐
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
August 15, 2021 - // 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
🌐
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\"?
🌐
Freshman Tech
freshman.tech › snippets › go › check-if-slice-contains-element
How to Check If a Slice Contains an Element in Go
February 7, 2024 - // 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)....
🌐
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   golang
🌐
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.
🌐
Reddit
reddit.com › r/golang › issues using strings.contains() function after converting an interface to string
r/golang on Reddit: Issues using strings.Contains() function after converting an interface to string
October 18, 2019 -

Hello, I've recently encountered an issue trying to use the strings.Contains( ) function after pulling values into an interface from a SQLite database. I am able to successfully use the converted string to print out its contents and set other variables but for some reason the strings.Contains() function doesn't like it. My question is what am I doing wrong and what would be the best way to go about verifying the content of the data pulled from the database?

Any and all help or criticism would be greatly appreciated! Thanks!

Snippet Here:

rows, err := db.Query(stmt)
if err != nil {
	log.Println(err, stmt, dbpath)
	return
}

columns, _ := rows.Columns()
count := len(columns)
values := make([]interface{}, count)
valuePtrs := make([]interface{}, count)

for rows.Next() {
	for cols := range columns {
		valuePtrs[cols] = &values[cols]
	}
	var recid int64
	// add metadata
	rows.Scan(valuePtrs...)
        var rid int64
        for ind, col := range columns {
        
        	val := values[ind] // interface 
        	if col == "rid" {
        		v, ok := val.(int64)
        		if ok {
        			recid = v
        		}
        		continue
        	}
        
        	if col == "sid" {
        		continue
        	}
        
        	value := fmt.Sprintf("%v", val)
        
        	for st := range searchTerms {
        		if strings.Contains(value, searchTerms[st]) { // issue here **************
                            ...