Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ go generate ./...

By default the generated type supports `encoding.TextMarshaler`/`Unmarshaler` (used by `encoding/json`). To include other integrations, enable flags as needed (see below).

### Constant Values

Enum constants may be written as constant expressions: `iota` with arithmetic, shifts and bitwise operators, literals in
any base, `len`, `min` and `max`, references to other constants of the same package, and conversions. As in Go, a
constant without an expression repeats the expression of the preceding one.

```go
type permission uint8

const (
permissionRead permission = 1 << iota // 1
permissionWrite // 2
permissionAdmin // 4
)
```

The generator reports an error when a value cannot be evaluated, for instance when it refers to a constant of another
package, and when a value does not fit the underlying type of the enum.

### Generator Options

- `-type` (required): the name of the type to generate enum for (must be lowercase/private)
Expand Down
Loading