MCPcopy Create free account
hub / github.com/goadesign/goa / fieldCode

Function fieldCode

http/codegen/server_types.go:222–249  ·  view source on GitHub ↗

fieldCode returns the code to initialize the return struct fields. It is used only in templates.

(init *InitData, typ string)

Source from the content-addressed store, hash-verified

220// fieldCode returns the code to initialize the return struct fields. It is
221// used only in templates.
222func fieldCode(init *InitData, typ string) string {
223 varn := "res"
224 if init.ReturnTypeAttribute == "" {
225 varn = "v"
226 }
227 args := init.ServerArgs
228 if typ == "client" {
229 args = init.ClientArgs
230 }
231 initArgs := make([]*codegen.InitArgData, len(args))
232 for i, arg := range args {
233 initArgs[i] = &codegen.InitArgData{
234 Name: arg.VarName,
235 Pointer: arg.Pointer,
236 Type: arg.Type,
237 FieldName: arg.FieldName,
238 FieldPointer: arg.FieldPointer,
239 FieldType: arg.FieldType,
240 }
241 }
242 // We can ignore the transform helpers as there won't be any generated
243 // because the headers and params cannot be user types.
244 c, _, err := codegen.InitStructFields(initArgs, varn, "", init.ReturnTypePkg)
245 if err != nil {
246 panic(err) // bug
247 }
248 return c
249}

Callers

nothing calls this directly

Calls 1

InitStructFieldsFunction · 0.92

Tested by

no test coverage detected