greeter.go 334 B

12345678910111213141516171819202122
  1. // greeter.go
  2. package main
  3. import "fmt"
  4. type Greeter struct {
  5. Message string
  6. }
  7. func NewGreeter(message string) *Greeter {
  8. return &Greeter{
  9. Message: message,
  10. }
  11. }
  12. func (g *Greeter) Greet() string {
  13. return fmt.Sprintf("Hello, %s!", g.Message)
  14. }
  15. func (g *Greeter) Name() string {
  16. return fmt.Sprintf("Hello, %s!", g.Message)
  17. }