code: func (codegen *CodeGenerator) Generate() (string, error) {
  	for index, rawSchema := range codegen.rawSchemas {
  		parsedSchema, err := ParseSchema(rawSchema)
  		if err != nil {
  			return "", err
  		}
  
  		schema, ok := parsedSchema.(*RecordSchema)
  		if !ok {
  			return "", errors.New("Not a Record schema.")
  		}
  		schemaInfo, err := newRecordSchemaInfo(schema)
  		if err != nil {
  			return "", err
  		}
  
  		buffer := &bytes.Buffer{}
  		codegen.codeSnippets = append(codegen.codeSnippets, buffer)
  
  		// write package and import only once
  		if index == 0 {
  			err = codegen.writePackageName(schemaInfo)
  			if err != nil {
  				return "", err
  			}
  
  			err = codegen.writeImportStatement()
  			if err != nil {
  				return "", err
  			}
  		}
  
  		err = codegen.writeStruct(schemaInfo)
  		if err != nil {
  			return "", err
  		}
  	}
  
  	formatted, err := format.Source([]byte(codegen.collectResult()))
  	if err != nil {
  		return "", err
  	}
  
  	return string(formatted), nil
  }
docs: // Generate generates source code for Avro schemas specified on creation.
  // The ouput is Go formatted source code that contains struct definitions for all given schemas.
  // May return an error if code generation fails, e.g. due to unparsable schema.