MCPcopy Index your code
hub / github.com/oapi-codegen/oapi-codegen / genParamArgs

Function genParamArgs

pkg/codegen/template_helpers.go:76–86  ·  view source on GitHub ↗

genParamArgs takes an array of Parameter definition, and generates a valid Go parameter declaration from them, eg: ", foo int, bar string, baz float32". The preceding comma is there to save a lot of work in the template engine.

(params []ParameterDefinition)

Source from the content-addressed store, hash-verified

74// ", foo int, bar string, baz float32". The preceding comma is there to save
75// a lot of work in the template engine.
76func genParamArgs(params []ParameterDefinition) string {
77 if len(params) == 0 {
78 return ""
79 }
80 parts := make([]string, len(params))
81 for i, p := range params {
82 paramName := p.GoVariableName()
83 parts[i] = fmt.Sprintf("%s %s", paramName, p.TypeDef())
84 }
85 return ", " + strings.Join(parts, ", ")
86}
87
88// genParamTypes is much like the one above, except it only produces the
89// types of the parameters for a type declaration. It would produce this

Callers

nothing calls this directly

Calls 2

GoVariableNameMethod · 0.80
TypeDefMethod · 0.45

Tested by

no test coverage detected