Debian Codegraph @

example/main.go

raw symbols SCIP
1 package main
2
3 import (
4 "fmt"
5
6 "github.com/muesli/combinator"
7 )
8
9 func main() {
10 type User struct {
11 Name string
12 Age uint
13 Admin bool
14 }
15
16 /*
17 Define potential test values. Make sure the struct's fields share the name and
18 type of the structs you want to generate.
19 */
20 testData := struct {
21 Name []string
22 Age []uint
23 Admin []bool
24 }{
25 Name: []string{"Alice", "Bob"},
26 Age: []uint{23, 42, 99},
27 Admin: []bool{false, true},
28 }
29
30 // Generate all possible combinations
31 var users []User
32 combinator.Generate(&users, testData)
33
34 for i, u := range users {
35 fmt.Printf("Combination %2d | Name: %-5s | Age: %d | Admin: %v\n", i, u.Name, u.Age, u.Admin)
36 }
37 }