Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix example generation #3547

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions codegen/service/example_svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func exampleServiceFile(genpkg string, _ *expr.RootExpr, svc *expr.ServiceExpr,
{Path: "fmt"},
{Path: "strings"},
{Path: path.Join(genpkg, svcName), Name: data.PkgName},
{Path: "goa.design/clue/log"},
{Path: "goa.design/goa/v3/security"},
}
sections := []*codegen.SectionTemplate{
Expand Down
2 changes: 1 addition & 1 deletion codegen/service/templates/endpoint.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ func (s *{{ .ServiceVarName }}srvc) {{ .VarName }}(ctx context.Context{{ if .Pay
{{- end }}
{{- end }}
{{- end }}
s.logger.Print("{{ .ServiceVarName }}.{{ .Name }}")
log.Print(ctx, "{{ .ServiceVarName }}.{{ .Name }}")
return
}
4 changes: 2 additions & 2 deletions codegen/service/templates/service_init.go.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ printf "New%s returns the %s service implementation." .StructName .Name | comment }}
func New{{ .StructName }}(logger *log.Logger) {{ .PkgName }}.Service {
return &{{ .VarName }}srvc{logger}
func New{{ .StructName }}() {{ .PkgName }}.Service {
return &{{ .VarName }}srvc{}
}
4 changes: 1 addition & 3 deletions codegen/service/templates/service_struct.go.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
{{ printf "%s service example implementation.\nThe example methods log the requests and return zero values." .Name | comment }}
type {{ .VarName }}srvc struct {
logger *log.Logger
}
type {{ .VarName }}srvc struct {}
2 changes: 1 addition & 1 deletion grpc/codegen/templates/server_grpc_end.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
if lis == nil {
errc <- fmt.Errorf("failed to listen on %q", u.Host)
}
logger.Printf("gRPC server listening on %q", u.Host)
log.Printf(ctx, "gRPC server listening on %q", u.Host)
errc <- srv.Serve(lis)
}()

Expand Down
2 changes: 1 addition & 1 deletion grpc/codegen/testdata/server-no-server.golden
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func handleGRPCServer(ctx context.Context, u *url.URL, serviceEndpoints *service
if lis == nil {
errc <- fmt.Errorf("failed to listen on %q", u.Host)
}
logger.Printf("gRPC server listening on %q", u.Host)
log.Printf(ctx, "gRPC server listening on %q", u.Host)
errc <- srv.Serve(lis)
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func handleGRPCServer(ctx context.Context, u *url.URL, serviceEndpoints *service
if lis == nil {
errc <- fmt.Errorf("failed to listen on %q", u.Host)
}
logger.Printf("gRPC server listening on %q", u.Host)
log.Printf(ctx, "gRPC server listening on %q", u.Host)
errc <- srv.Serve(lis)
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func handleGRPCServer(ctx context.Context, u *url.URL, serviceEndpoints *service
if lis == nil {
errc <- fmt.Errorf("failed to listen on %q", u.Host)
}
logger.Printf("gRPC server listening on %q", u.Host)
log.Printf(ctx, "gRPC server listening on %q", u.Host)
errc <- srv.Serve(lis)
}()

Expand Down