code: func generateUnion(ctx *context, w io.Writer, union *Union) {
  	name := camelCaseName(union.Name)
  
  	logf(" writing union %q (%s) with %d fields", union.Name, name, len(union.Fields))
  
  	// generate struct comment
  	generateComment(ctx, w, name, union.Name, "union")
  
  	// generate struct definition
  	fmt.Fprintln(w, "type", name, "struct {")
  
  	// maximum size for union
  	maxSize := getUnionSize(ctx, union)
  
  	// generate data field
  	fieldName := "Union_data"
  	fmt.Fprintf(w, "\t%s [%d]byte\n", fieldName, maxSize)
  
  	// generate end of the struct
  	fmt.Fprintln(w, "}")
  
  	// generate name getter
  	generateTypeNameGetter(w, name, union.Name)
  
  	// generate CRC getter
  	generateCrcGetter(w, name, union.CRC)
  
  	// generate getters for fields
  	for _, field := range union.Fields {
  		fieldName := camelCaseName(field.Name)
  		fieldType := convertToGoType(ctx, field.Type)
  		generateUnionGetterSetter(w, name, fieldName, fieldType)
  	}
  
  	// generate union methods
  	//generateUnionMethods(w, name)
  
  	fmt.Fprintln(w)
  }
docs: // generateUnion writes generated code for the union into w