|
| 1 | +package example |
| 2 | + |
| 3 | +import ( |
| 4 | + "math/rand" |
| 5 | + "time" |
| 6 | +) |
| 7 | + |
| 8 | +// This is an unrelated type that should be ignored by the enumify generator. |
| 9 | +type Example struct { |
| 10 | + Name string |
| 11 | + Day Day |
| 12 | + Status Status |
| 13 | + Date time.Time |
| 14 | + Tags []string |
| 15 | +} |
| 16 | + |
| 17 | +// This is an unrelated function that should be ignored by the enumify generator. |
| 18 | +func New() (*Example, error) { |
| 19 | + adjectives := exampleNames[0] |
| 20 | + nouns := exampleNames[1] |
| 21 | + name := adjectives[rand.Intn(len(adjectives))] + " " + nouns[rand.Intn(len(nouns))] |
| 22 | + |
| 23 | + day := Day(rand.Intn(int(Sunday) + 1)) |
| 24 | + status := Status(rand.Intn(int(StatusCancelled) + 1)) |
| 25 | + |
| 26 | + now := time.Now() |
| 27 | + date := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local) |
| 28 | + |
| 29 | + n := rand.Intn(6) // 0–5 tags |
| 30 | + tags := make([]string, n) |
| 31 | + for i := range tags { |
| 32 | + tags[i] = exampleTags[rand.Intn(len(exampleTags))] |
| 33 | + } |
| 34 | + |
| 35 | + return &Example{ |
| 36 | + Name: name, |
| 37 | + Day: day, |
| 38 | + Status: status, |
| 39 | + Date: date, |
| 40 | + Tags: tags, |
| 41 | + }, nil |
| 42 | +} |
| 43 | + |
| 44 | +// This is an unrelated variable that should be ignored by the enumify generator. |
| 45 | +var exampleTags = []string{ |
| 46 | + "low", "medium", "high", |
| 47 | + "red", "green", "blue", |
| 48 | + "primary", "secondary", "success", "danger", "warning", "info", |
| 49 | + "foo", "bar", "baz", |
| 50 | +} |
| 51 | + |
| 52 | +// This is an unrelated 2D array that should be ignored by the enumify generator. |
| 53 | +var exampleNames = [][]string{ |
| 54 | + {"curious", "ancient", "vibrant", "subtle", "brittle", "serene", "chaotic", "luminous", "hollow", "nimble", "terse", "ornate"}, |
| 55 | + {"mountain", "river", "castle", "lighthouse", "violin", "compass", "telescope", "orchard", "glacier", "harbor", "cathedral", "parchment"}, |
| 56 | +} |
0 commit comments