From 5d872a540b4f2d14e674a5b704b48fa48469a397 Mon Sep 17 00:00:00 2001 From: Mat Ryer Date: Wed, 21 Sep 2016 21:55:13 +0100 Subject: [PATCH] minor improvements --- main.go | 2 +- package/moq/moq.go | 9 +++------ package/moq/moq_test.go | 11 ----------- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/main.go b/main.go index 7b6dc44..51fbbea 100644 --- a/main.go +++ b/main.go @@ -13,7 +13,7 @@ func main() { var err error defer func() { if err != nil { - fmt.Println(err) + fmt.Fprintln(os.Stderr, err) flag.Usage() os.Exit(1) } diff --git a/package/moq/moq.go b/package/moq/moq.go index f36a3f2..40b80e7 100644 --- a/package/moq/moq.go +++ b/package/moq/moq.go @@ -80,7 +80,6 @@ func (m *Mocker) Mock(w io.Writer, name ...string) error { iface := tpkg.Scope().Lookup(n) if iface == nil { return fmt.Errorf("cannot find interface %s", n) - continue } if !types.IsInterface(iface.Type()) { return fmt.Errorf("%s (%s) not an interface", n, iface.Type().String()) @@ -190,8 +189,7 @@ func (p param) TypeString() string { return p.Type } -var moqTemplate = ` -package {{.PackageName}} +var moqTemplate = `package {{.PackageName}} // AUTOGENERATED BY MOQ // github.com/matryer/moq @@ -224,6 +222,5 @@ func (mock *{{$obj.InterfaceName}}Mock) {{.Name}}({{.Arglist}}) {{.ReturnArglist } return mock.{{.Name}}Func({{.ArgCallList}}) } -{{ end }} -{{ end }} -` +{{ end -}} +{{ end -}}` diff --git a/package/moq/moq_test.go b/package/moq/moq_test.go index 7249cf7..6a5d74b 100644 --- a/package/moq/moq_test.go +++ b/package/moq/moq_test.go @@ -2,13 +2,11 @@ package moq import ( "bytes" - "log" "strings" "testing" ) func TestMoq(t *testing.T) { - m, err := New("../../example", "") if err != nil { t.Errorf("moq.New: %s", err) @@ -19,9 +17,6 @@ func TestMoq(t *testing.T) { t.Errorf("m.Mock: %s", err) } s := buf.String() - - log.Println(s) - // assertions of things that should be mentioned var strs = []string{ "package example", @@ -36,11 +31,9 @@ func TestMoq(t *testing.T) { t.Errorf("expected but missing: \"%s\"", str) } } - } func TestMoqExplicitPackage(t *testing.T) { - m, err := New("../../example", "different") if err != nil { t.Errorf("moq.New: %s", err) @@ -51,9 +44,6 @@ func TestMoqExplicitPackage(t *testing.T) { t.Errorf("m.Mock: %s", err) } s := buf.String() - - log.Println(s) - // assertions of things that should be mentioned var strs = []string{ "package different", @@ -68,5 +58,4 @@ func TestMoqExplicitPackage(t *testing.T) { t.Errorf("expected but missing: \"%s\"", str) } } - }