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

Function ExampleServiceFiles

codegen/service/example_svc.go:38–57  ·  view source on GitHub ↗

ExampleServiceFiles returns a basic service implementation for every service expression.

(genpkg string, root *expr.RootExpr, services *ServicesData)

Source from the content-addressed store, hash-verified

36// ExampleServiceFiles returns a basic service implementation for every
37// service expression.
38func ExampleServiceFiles(genpkg string, root *expr.RootExpr, services *ServicesData) []*codegen.File {
39 // determine the unique API package name different from the service names
40 scope := codegen.NewNameScope()
41 for _, svc := range root.Services {
42 s := services.Get(svc.Name)
43 if s == nil {
44 panic("unknown service, " + svc.Name) // bug
45 }
46 scope.Unique(s.PkgName)
47 }
48 apipkg := scope.Unique(strings.ToLower(codegen.Goify(root.API.Name, false)), "api")
49
50 var fw []*codegen.File
51 for _, svc := range root.Services {
52 if f := exampleServiceFile(genpkg, root, svc, services, apipkg); f != nil {
53 fw = append(fw, f)
54 }
55 }
56 return fw
57}
58
59// exampleServiceFile returns a basic implementation of the given service.
60func exampleServiceFile(genpkg string, _ *expr.RootExpr, svc *expr.ServiceExpr, services *ServicesData, apipkg string) *codegen.File {

Callers 2

ExampleFunction · 0.92
TestExampleServiceFilesFunction · 0.85

Calls 5

UniqueMethod · 0.95
NewNameScopeFunction · 0.92
GoifyFunction · 0.92
exampleServiceFileFunction · 0.85
GetMethod · 0.45

Tested by 1

TestExampleServiceFilesFunction · 0.68