github.com/aacfactory/avro@v1.2.12/internal/base/schema_walk.go (about)

     1  package base
     2  
     3  func walkSchema(schema Schema, fn func(Schema) Schema) Schema {
     4  	schema = fn(schema)
     5  
     6  	switch s := schema.(type) {
     7  	case *RecordSchema:
     8  		for _, f := range s.Fields() {
     9  			f.typ = walkSchema(f.typ, fn)
    10  		}
    11  	case *ArraySchema:
    12  		s.items = walkSchema(s.items, fn)
    13  	case *MapSchema:
    14  		s.values = walkSchema(s.values, fn)
    15  	case *UnionSchema:
    16  		for i, st := range s.types {
    17  			s.types[i] = walkSchema(st, fn)
    18  		}
    19  	}
    20  	return schema
    21  }