https://github.com/heapwolf/go-indexof
The IndexOf() method returns the first index at which a given element can be found in the slice, or -1 if it is not present.
https://github.com/heapwolf/go-indexof
Last synced: about 1 month ago
JSON representation
The IndexOf() method returns the first index at which a given element can be found in the slice, or -1 if it is not present.
- Host: GitHub
- URL: https://github.com/heapwolf/go-indexof
- Owner: heapwolf
- License: mit
- Created: 2015-05-04T12:48:34.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2020-10-22T10:07:00.000Z (over 4 years ago)
- Last Synced: 2025-03-29T19:11:09.209Z (about 2 months ago)
- Language: Go
- Size: 2.93 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SYOPSIS
The IndexOf() method returns the first index at which a given element can
be found in the slice, or -1 if it is not present. The only requirement of
this function is that the second argument must be a slice.# INSTALL
```bash
go get github.com/hij1nx/go-indexof
```# USAGE
```go
import "github.com/hij1nx/go-indexof"var v = "bazz"
var a = []string{"bar", "foo", "bazz"}var i = IndexOf(v, a) // "i" is assigned "2"
var v = 20
var a = []int{10, 20, 30}var i = IndexOf(v, a) // "i" is assigned "1"
```