func location(p *gen.ActionParam) string {
	switch p.Location {
	case gen.PathParam:
		return "metadata.PathParam"
	case gen.QueryParam:
		return "metadata.QueryParam"
	case gen.PayloadParam:
		return "metadata.PayloadParam"
	default:
		return ""
	}
}
Return code corresponding to param location
package writers
import (
	"io"
	"strings"
	"text/template"
	"github.com/rightscale/rsc/gen"
)
type MetadataWriter struct {
	headerTmpl   *template.Template
	resourceTmpl *template.Template
}
func NewMetadataWriter() (*MetadataWriter, error) {
	funcMap := template.FuncMap{
		"comment":         comment,
		"join":            strings.Join,
		"commandLine":     commandLine,
		"toStringArray":   toStringArray,
		"flagType":        flagType,
		"location":        location,
		"escapeBackticks": escapeBackticks,
	}
	headerT, err := template.New("header-metadata").Funcs(funcMap).Parse(headerMetadataTmpl)
	if err != nil {
		return nil, err
	}
	resourceT, err := template.New("resource-metadata").Funcs(funcMap).Parse(resourceMetadataTmpl)
	if err != nil {
		return nil, err
	}
	return &MetadataWriter{
		headerTmpl:   headerT,
		resourceTmpl: resourceT,
	}, nil
}
func (c *MetadataWriter) WriteHeader(pkg string, w io.Writer) error {
	return c.headerTmpl.Execute(w, pkg)
}
func (c *MetadataWriter) WriteMetadata(d *gen.APIDescriptor, w io.Writer) error {
	resources := make([]*gen.Resource, len(d.ResourceNames))
	for i, n := range d.ResourceNames {
		resources[i] = d.Resources[n]
	}
	return c.resourceTmpl.Execute(w, resources)
}