code: func BuildEncoders(info []*design.EncodingDefinition, encoder bool) ([]*EncoderTemplateData, error) {
  	if len(info) == 0 {
  		return nil, nil
  	}
  	// knownStdPackages lists the stdlib packages known by BuildEncoders
  	var knownStdPackages = map[string]string{
  		"encoding/json": "json",
  		"encoding/xml":  "xml",
  		"encoding/gob":  "gob",
  	}
  	encs := normalizeEncodingDefinitions(info)
  	data := make([]*EncoderTemplateData, len(encs))
  	defaultMediaType := info[0].MIMETypes[0]
  	for i, enc := range encs {
  		var pkgName string
  		if name, ok := knownStdPackages[enc.PackagePath]; ok {
  			pkgName = name
  		} else {
  			srcPath, err := codegen.PackageSourcePath(enc.PackagePath)
  			if err != nil {
  				return nil, fmt.Errorf("failed to locate package source of %s (%s)",
  					enc.PackagePath, err)
  			}
  			pkgName, err = codegen.PackageName(srcPath)
  			if err != nil {
  				return nil, fmt.Errorf("failed to load package %s (%s)",
  					enc.PackagePath, err)
  			}
  		}
  		isDefault := false
  		for _, m := range enc.MIMETypes {
  			if m == defaultMediaType {
  				isDefault = true
  			}
  		}
  		d := &EncoderTemplateData{
  			PackagePath: enc.PackagePath,
  			PackageName: pkgName,
  			Function:    enc.Function,
  			MIMETypes:   enc.MIMETypes,
  			Default:     isDefault,
  		}
  		data[i] = d
  	}
  	return data, nil
  }
docs: // BuildEncoders builds the template data needed to render the given encoding definitions.
  // This extra map is needed to handle the case where a single encoding definition maps to multiple
  // encoding packages. The data is indexed by mime type.