Skip to content

Commit

Permalink
doc: added types to be generated section
Browse files Browse the repository at this point in the history
  • Loading branch information
miyamo2 committed Aug 27, 2024
1 parent b0a196f commit b32ba3c
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,48 +103,73 @@ For the actual generated code, see the [example](https://github.com/miyamo2/filt

## Features

### Types to be generated

`filtgen` generates the following defined-types.
Type name is determined by the struct name; e.g. `User` -> `UserSlice`.
To use the generated methods, cast must be performed.
```go
s := []User{
{Name: "Alice"},
{Name: "Bob"},
}
for i, v := range UserSlice(s).NameEq("Alice") {
fmt.Printf("%d: %s\n", i, v.Name)
}
```

`XxxSlice`(`[]T`)

`XxxMap[K]`(`map[K compareble]T`)

`XxxSeq[T]`(`iter.Seq[T]`)

`XxxSeq2[T]`(`iter.Seq2[T, U]`)

### Methods to be generated

Following methods are generated by `filtgen`.
Method name is determined by the field name; e.g. `Name` -> `NameEq`.

### `XxxEq`
#### `XxxEq`

Selects iterator items whose field values are equal to the specified value.

### `XxxNe`
#### `XxxNe`

Selects iterator items whose field values are not equal to the specified value.

### `XxxGt`
#### `XxxGt`

Selects iterator items whose field values are greater than the specified value.

### `XxxLt`
#### `XxxLt`

Selects iterator items whose field values are less than the specified value.

### `XxxGe`
#### `XxxGe`

Selects iterator items whose field values are greater than or equal to the specified value.

### `XxxLe`
#### `XxxLe`

Selects iterator items whose field values are less than or equal to the specified value.

### `XxxMatches`
#### `XxxMatches`

Selects iterator items whose field values match the specified function.

### `XxxIs`
#### `XxxIs`

Selects iterator items whose field values are equal to the specified `error`.
Equivalence is determined by `errors.Is`.

### `XxxIsnt`
#### `XxxIsnt`

Selects iterator items whose field values are not equal to the specified `error`.
Equivalence is determined by `errors.Is`.

## List of compatible filters by type
#### List of compatible filters by type

| Type\Filter | `XxxEq` | `XxxNe` | `XxxGt` | `XxxLt` | `XxxGe` | `XxxLe` | `XxxMatches` | `XxxIs` | `XxxIsnt` |
|--------------|---------|---------|---------|---------|---------|---------|--------------|---------|-----------|
Expand All @@ -169,7 +194,7 @@ Equivalence is determined by `errors.Is`.
| `bool` ||||||||||
| other-types ||||||||||

## `filtgen` tags
### `filtgen` tags

The following values can be set in the `filtgen` tag.
If you want to set multiple values, separate them with `,`.
Expand Down

0 comments on commit b32ba3c

Please sign in to comment.