forked from bradleygore/gomock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
greeter.go
31 lines (24 loc) · 765 Bytes
/
greeter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package greeter
//go:generate mockgen -source greeter.go -destination greeter_mock_test.go -package greeter
import (
// stdlib import
"fmt"
// non-matching import suffix and package name
"github.com/jpparker/gomock/mockgen/internal/tests/custom_package_name/client/v1"
// matching import suffix and package name
"github.com/jpparker/gomock/mockgen/internal/tests/custom_package_name/validator"
)
type InputMaker interface {
MakeInput() client.GreetInput
}
type Greeter struct {
InputMaker InputMaker
Client *client.Client
}
func (g *Greeter) Greet() (string, error) {
in := g.InputMaker.MakeInput()
if err := validator.Validate(in.Name); err != nil {
return "", fmt.Errorf("validation failed: %v", err)
}
return g.Client.Greet(in), nil
}