-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Scan method for ResultSet to scan the rows into the given slice (…
…Part 1) (#298) * Add Scan for ResultSet * drop supports for Go 1.16 and 1.17 Update test.yaml * Revert "drop supports for Go 1.16 and 1.17" This reverts commit 2478f44. * Supports Go 1.16+
- Loading branch information
Xin Hao
authored
Jan 11, 2024
1 parent
6eb07e9
commit 3fe0bb1
Showing
6 changed files
with
135 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package nebula_go | ||
|
||
func IndexOf(collection []string, element string) int { | ||
for i, item := range collection { | ||
if item == element { | ||
return i | ||
} | ||
} | ||
|
||
return -1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package nebula_go | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestUtil_IndexOf(t *testing.T) { | ||
collection := []string{"a", "b", "c"} | ||
assert.Equal(t, IndexOf(collection, "a"), 0) | ||
assert.Equal(t, IndexOf(collection, "b"), 1) | ||
assert.Equal(t, IndexOf(collection, "c"), 2) | ||
assert.Equal(t, IndexOf(collection, "d"), -1) | ||
} |