github.com/blend/go-sdk@v1.20240719.1/slices/slices.go (about) 1 /* 2 3 Copyright (c) 2024 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package slices 9 10 // Index returns the index of the first occurrence of v in s, 11 // or -1 if not present. 12 func Index[E comparable](s []E, v E) int { 13 for i := range s { 14 if v == s[i] { 15 return i 16 } 17 } 18 return -1 19 } 20 21 // Contains reports whether v is present in s. 22 func Contains[E comparable](s []E, v E) bool { 23 return Index(s, v) >= 0 24 }