Documentation
¶
Overview ¶
Package constforms exercises the const shapes a `swagger:enum` member can take beyond a plain literal — the shapes that are invisible to a reader working on literal syntax alone, and which the go-swagger#3412 investigation surfaced one after the other:
- `iota`, where only the first spec of the block carries a type and a value at all and every following spec inherits both implicitly;
- constant expressions and references to earlier members (`1 << 3`, `LevelLow * 2`);
- rune literals, whose constant is an integer (`'a'` is 97, not the three characters `'a'`);
- `true` / `false`, which are predeclared identifiers rather than literals — Go has no boolean literal token;
- raw and escaped strings, whose delimiters and escape sequences are part of the syntax, not of the value.
Values come from the type-checker, which has already evaluated every one of these exactly.
Index ¶
Constants ¶
const ForeignDay foreign.Weekday = 13
ForeignDay is declared HERE but typed with an imported type that happens to be called Weekday too. Membership is decided by type identity, not by name, so it is not a member of the enum above.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Byte ¶
type Byte byte
Byte is a byte enum, whose members are written as rune literals.
swagger:enum Byte
type Label ¶
type Label string
Label is a string enum in the raw and escaped literal forms.
swagger:enum Label
type Level ¶
type Level int
Level is built from a constant expression and a reference to an earlier member.
swagger:enum Level
type Settings ¶
type Settings struct {
// The day of the week.
Weekday Weekday `json:"weekday"`
// The level.
Level Level `json:"level"`
// The letter.
Letter Letter `json:"letter"`
// The toggle.
Toggle Toggle `json:"toggle"`
// The label.
Label Label `json:"label"`
// The byte.
Byte Byte `json:"byte"`
}
Settings carries one property per const form.
swagger:model Settings
Directories
¶
| Path | Synopsis |
|---|---|
|
Package foreign declares a type sharing its name with an enum type of the parent package, so the membership test cannot be name-only.
|
Package foreign declares a type sharing its name with an enum type of the parent package, so the membership test cannot be name-only. |