code: func generateType(ctx *context, w io.Writer, typ *Type) {
  	name := camelCaseName(typ.Name)
  
  	logf(" writing type %q (%s) with %d fields", typ.Name, name, len(typ.Fields))
  
  	// generate struct comment
  	generateComment(ctx, w, name, typ.Name, "type")
  
  	// generate struct definition
  	fmt.Fprintf(w, "type %s struct {\n", name)
  
  	// generate struct fields
  	for i, field := range typ.Fields {
  		// skip internal fields
  		switch strings.ToLower(field.Name) {
  		case crcField, msgIdField:
  			continue
  		}
  
  		generateField(ctx, w, typ.Fields, i)
  	}
  
  	// generate end of the struct
  	fmt.Fprintln(w, "}")
  
  	// generate name getter
  	generateTypeNameGetter(w, name, typ.Name)
  
  	// generate CRC getter
  	generateCrcGetter(w, name, typ.CRC)
  
  	fmt.Fprintln(w)
  }
docs: // generateType writes generated code for the type into w