Skip to content

Commit 4f1f56a

Browse files
committed
feat: convert Test struct to exported
1 parent fd53232 commit 4f1f56a

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,29 +2105,29 @@ It returns a new slice containing only the elements whose keys are not in the ex
21052105

21062106

21072107
```go
2108-
type user {
2109-
id int
2110-
name string
2108+
type User {
2109+
ID int
2110+
Name string
21112111
}
21122112

21132113
// original users
2114-
users := []user{
2115-
{id: 1, name: "Alice"},
2116-
{id: 2, name: "Bob"},
2117-
{id: 3, name: "Charlie"},
2114+
users := []User{
2115+
{ID: 1, Name: "Alice"},
2116+
{ID: 2, Name: "Bob"},
2117+
{ID: 3, Name: "Charlie"},
21182118
}
21192119

21202120
// exclude users with IDs 2 and 3
21212121
excludedIDs := []int{2, 3}
21222122

21232123
// extract function to get the user ID
2124-
extractID := func(user user) int {
2125-
return user.id
2124+
extractID := func(user User) int {
2125+
return user.ID
21262126
}
21272127

21282128
// filtering users
21292129
filteredUsers := WithoutBy(users, extractID, excludedIDs...)
2130-
// []user[{id: 1, name: "Alice"}]
2130+
// []User[{ID: 1, Name: "Alice"}]
21312131
```
21322132

21332133
### WithoutEmpty

intersect_example_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ import (
55
)
66

77
func ExampleWithoutBy() {
8-
type user struct {
9-
id int
10-
name string
8+
type User struct {
9+
ID int
10+
Name string
1111
}
1212
// original users
13-
users := []user{
14-
{id: 1, name: "Alice"},
15-
{id: 2, name: "Bob"},
16-
{id: 3, name: "Charlie"},
13+
users := []User{
14+
{ID: 1, Name: "Alice"},
15+
{ID: 2, Name: "Bob"},
16+
{ID: 3, Name: "Charlie"},
1717
}
1818

1919
// exclude users with IDs 2 and 3
2020
excludedIDs := []int{2, 3}
2121

2222
// extract function to get the user ID
23-
extractID := func(user user) int {
24-
return user.id
23+
extractID := func(user User) int {
24+
return user.ID
2525
}
2626

2727
// filtering users

intersect_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,20 @@ func TestWithoutBy(t *testing.T) {
274274
t.Parallel()
275275
is := assert.New(t)
276276

277-
type user struct {
278-
name string
279-
age int
277+
type User struct {
278+
Name string
279+
Age int
280280
}
281281

282-
result1 := WithoutBy([]user{{name: "nick"}, {name: "peter"}},
283-
func(item user) string {
284-
return item.name
282+
result1 := WithoutBy([]User{{Name: "nick"}, {Name: "peter"}},
283+
func(item User) string {
284+
return item.Name
285285
}, "nick", "lily")
286-
result2 := WithoutBy([]user{}, func(item user) int { return item.age }, 1, 2, 3)
287-
result3 := WithoutBy([]user{}, func(item user) string { return item.name })
288-
is.Equal(result1, []user{{name: "peter"}})
289-
is.Equal(result2, []user{})
290-
is.Equal(result3, []user{})
286+
result2 := WithoutBy([]User{}, func(item User) int { return item.Age }, 1, 2, 3)
287+
result3 := WithoutBy([]User{}, func(item User) string { return item.Name })
288+
is.Equal(result1, []User{{Name: "peter"}})
289+
is.Equal(result2, []User{})
290+
is.Equal(result3, []User{})
291291
}
292292

293293
func TestWithoutEmpty(t *testing.T) {

0 commit comments

Comments
 (0)