In Go language slice is more powerful, flexible, convenient than an array, and is a lightweight data structure. The slice is a variable-length sequence which stores elements of a similar type, you are not allowed to store different type of elements in the same slice.
In the Go slice, you can search an element of string type in the given slice of strings with the help of SearchStrings() function. This function searches for the given element in a sorted slice of strings and returns the index of that element if present in the given slice. And if the given element is not available in the slice(it could be len(s_slice)), then it returns the index to insert the element in the slice. The specified slice must be sorted in ascending order. It is defined under the sort package so, you have to import sort package in your program for accessing SearchStrings function.
func SearchStrings(s_slice string, s string64) int
Slice 1: [C C# Go Java Ruby] Slice 2: [123geeks GEEKs GeeksforGeeks gfg] Result 1: 2 Result 2: 1 Result 3: 3
Result 1: 2 Result 2: 0
- Searching an element of float64 type in Golang slice
- Golang | Searching an element of int type in slice of ints
- How to copy one slice into another slice in Golang?
- Check if the specified element is present in the slice of bytes in Golang
- How to replace a specified element in slice of bytes in Golang?
- How to find the index value of any element in slice of bytes in Golang?
- How to find the last index value of any element in slice of bytes in Golang?
- How to Get First and Last Element of Slice in Golang?
- Type Casting or Type Conversion in Golang
- How to convert a slice of bytes in uppercase in Golang?
- How to convert a slice of bytes in lowercase in Golang?
- Check if the given slice is sorted in Golang
- How to pass a Slice to Function in Golang?
- How to Sort a Slice of Strings in Golang?
- How to count specific characters present in the slice in Golang?
- How to sort a slice of ints in Golang?
- How to sort a slice of float64s in Golang?
- Checking Slice of bytes for equality under Unicode case folding in Golang
- Check if the Slice of bytes starts with specified prefix in Golang
- Check if the Slice of bytes ends with specified suffix in Golang
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.