12345678910111213141516171819202122 |
- // greeter.go
- package main
- import "fmt"
- type Greeter struct {
- Message string
- }
- func NewGreeter(message string) *Greeter {
- return &Greeter{
- Message: message,
- }
- }
- func (g *Greeter) Greet() string {
- return fmt.Sprintf("Hello, %s!", g.Message)
- }
- func (g *Greeter) Name() string {
- return fmt.Sprintf("Hello, %s!", g.Message)
- }
|