check string contains golang

To check if a string in the Go programming language contains the word "golang," you can follow these steps:

  1. Start by importing the necessary Go package for string manipulation, called "strings." This package provides various functions to work with strings.

  2. Declare a variable to store the input string that you want to check.

  3. Use the strings.Contains() function to check if the input string contains the word "golang." This function takes two arguments: the input string and the substring you want to check for. It returns a boolean value indicating whether the substring is present in the input string.

  4. Assign the result of the strings.Contains() function to a boolean variable. This variable will hold the result of the check.

  5. You can then use the boolean variable to perform further actions based on whether the input string contains "golang" or not.

Here's an example code snippet that demonstrates these steps:

package main

import (
    "fmt"
    "strings"
)

func main() {
    input := "I love golang programming language"

    containsGolang := strings.Contains(input, "golang")

    fmt.Println(containsGolang)
}

In this example, the input string is "I love golang programming language," and we are checking if it contains the word "golang." The output of this code will be true because the input string does indeed contain the word "golang."