MCPcopy Index your code
hub / github.com/expr-lang/expr / main

Function main

test/gen/gen.go:79–136  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

77}
78
79func main() {
80 runtime.GOMAXPROCS(runtime.NumCPU())
81
82 var corpus = make(map[string]struct{})
83 var corpusMutex sync.Mutex
84
85 numWorkers := runtime.NumCPU()
86 var wg sync.WaitGroup
87 wg.Add(numWorkers)
88
89 for i := 0; i < numWorkers; i++ {
90 go func(workerID int) {
91 defer func() {
92 if r := recover(); r != nil {
93 fmt.Printf("Worker %d recovered from panic: %v\n", workerID, r)
94 debug.PrintStack()
95 }
96 }()
97
98 defer wg.Done()
99 for {
100 var code string
101
102 code = node(oneOf(list[int]{
103 {3, 100},
104 {4, 40},
105 {5, 50},
106 {6, 30},
107 {7, 20},
108 {8, 10},
109 {9, 5},
110 {10, 5},
111 }))
112
113 program, err := expr.Compile(code, expr.Env(Env))
114 if err != nil {
115 continue
116 }
117 _, err = expr.Run(program, Env)
118 if err != nil {
119 continue
120 }
121
122 corpusMutex.Lock()
123 if _, exists := corpus[code]; exists {
124 corpusMutex.Unlock()
125 continue
126 }
127 corpus[code] = struct{}{}
128 corpusMutex.Unlock()
129
130 fmt.Println(code)
131 }
132 }(i)
133 }
134
135 wg.Wait()
136}

Callers

nothing calls this directly

Calls 8

CompileFunction · 0.92
EnvStruct · 0.92
RunFunction · 0.92
nodeFunction · 0.85
oneOfFunction · 0.85
PrintfMethod · 0.80
PrintlnMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…