24 lines
491 B
Go
24 lines
491 B
Go
package greet
|
|
|
|
import (
|
|
"context"
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
type Service struct{}
|
|
|
|
func NewService() *Service {
|
|
return &Service{}
|
|
}
|
|
|
|
// Greet returns a greeting message for the given name.
|
|
// If name is empty, it defaults to "world".
|
|
// Implements the Greeter interface.
|
|
func (s *Service) Greet(ctx context.Context, name string) string {
|
|
log.Trace().Ctx(ctx).Str("name", name).Msg("Greet function called")
|
|
|
|
if name == "" {
|
|
return "Hello world!"
|
|
}
|
|
return "Hello " + name + "!"
|
|
} |