Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 25 days 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 (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-10-22T10:07:00.000Z (about 4 years ago)
- Last Synced: 2024-10-18T17:08:51.568Z (26 days ago)
- Language: Go
- Size: 2.93 KB
- Stars: 7
- Watchers: 3
- 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"
```