INNER CODE UNIT · Go
arrayEqualCases
expr-lang/expr · vm/runtime/helpers/main.go:93
func arrayEqualCases(xs ...[]string) string {
var types []string
for _, x := range xs {
types = append(types, x...)
}
_, _ = fmt.Fprintf(os.Stderr, "Generating array equal cases for %v\n", types)
var out string
echo := func(s string, xs ...any) {
out += fmt.Sprintf(s, xs...) + "\n"
}
echo(`case []any:`)
echo(`switch y := b.(type) {`)
for _, a := range append(types, "any") {
echo(`case []%v:`, a)
echo(`if len(x) != len(y) { return false }`)
echo(`for i := range x {`)