Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-go
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
1f3d64cb
Commit
1f3d64cb
authored
1 year ago
by
ko_oler
Browse files
Options
Downloads
Patches
Plain Diff
GetByFunc -> GetElemFn
parent
3a9f4271
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/data/list.go
+1
-1
1 addition, 1 deletion
pkg/data/list.go
pkg/data/list_test.go
+2
-2
2 additions, 2 deletions
pkg/data/list_test.go
with
3 additions
and
3 deletions
pkg/data/list.go
+
1
−
1
View file @
1f3d64cb
...
...
@@ -104,7 +104,7 @@ func SetFromSlice[T comparable](input []T) []T {
return
s
}
func
Get
ByFunc
[
T
any
](
input
[]
T
,
f
func
(
v
T
)
bool
)
T
{
func
Get
ElemFn
[
T
any
](
input
[]
T
,
f
func
(
v
T
)
bool
)
T
{
var
result
T
for
_
,
val
:=
range
input
{
if
f
(
val
)
{
...
...
This diff is collapsed.
Click to expand it.
pkg/data/list_test.go
+
2
−
2
View file @
1f3d64cb
...
...
@@ -155,7 +155,7 @@ func TestSliceToMap(t *testing.T) {
assert
.
Equal
(
t
,
map
[
string
]
*
KV
{
"a"
:
{
"a"
,
"1"
},
"b"
:
{
"b"
,
"2"
},
"c"
:
{
"c"
,
"3"
}},
m
)
}
func
TestGet
ByFunc
(
t
*
testing
.
T
)
{
func
TestGet
ElemFn
(
t
*
testing
.
T
)
{
type
test
struct
{
ID
string
}
...
...
@@ -181,7 +181,7 @@ func TestGetByFunc(t *testing.T) {
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
got
:=
Get
ByFunc
(
tt
.
input
,
func
(
v
test
)
bool
{
return
v
.
ID
==
tt
.
id
})
got
:=
Get
ElemFn
(
tt
.
input
,
func
(
v
test
)
bool
{
return
v
.
ID
==
tt
.
id
})
assert
.
Equalf
(
t
,
tt
.
want
,
got
,
"GetByID(%v)"
,
tt
.
input
)
})
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment