Skip to content

Commit

Permalink
Update code to work at Go tip.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsymonds committed Jan 6, 2012
1 parent 8c10716 commit 7d1b033
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Object files and binaries from go.
.*\.[568]$
*.[568]

# Library files.
.*\.a$
*.a

# Any file prefixed by an underscore.
.*\/_.*
*/_*

# The mockgen binary.
mockgen/mockgen

# A binary produced by gotest.
gomock/[568]\.out
#gomock/[568]\.out
6 changes: 3 additions & 3 deletions gomock/matchers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package gomock_test

import (
"os"
"errors"
"testing"

"github.com/dsymonds/gomock/gomock"
Expand All @@ -32,8 +32,8 @@ func TestMatchers(t *testing.T) {
testCase{gomock.Any(), []e{3, nil, "foo"}, nil},
testCase{gomock.Eq(4), []e{4}, []e{3, "blah", nil, int64(4)}},
testCase{gomock.Nil(),
[]e{nil, (os.Error)(nil), (chan bool)(nil), (*int)(nil)},
[]e{"", 0, make(chan bool), os.NewError("err"), new(int)}},
[]e{nil, (error)(nil), (chan bool)(nil), (*int)(nil)},
[]e{"", 0, make(chan bool), errors.New("err"), new(int)}},
testCase{gomock.Not(gomock.Eq(4)), []e{3, "blah", nil, int64(4)}, []e{4}},
}
for i, test := range tests {
Expand Down
10 changes: 5 additions & 5 deletions mockgen/mockgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var (
auxInterfaces = make(map[string]map[string]*ast.InterfaceType)
)

func parseAuxFiles(auxFiles string) os.Error {
func parseAuxFiles(auxFiles string) error {
auxFiles = strings.TrimSpace(auxFiles)
if auxFiles == "" {
return nil
Expand Down Expand Up @@ -370,7 +370,7 @@ func (g *generator) ScanImports(file *ast.File) {
}
}

func (g *generator) Generate(file *ast.File, pkg string) os.Error {
func (g *generator) Generate(file *ast.File, pkg string) error {
g.p("// Automatically generated by MockGen. DO NOT EDIT!")
g.p("// Source: %v", g.filename)
g.p("")
Expand Down Expand Up @@ -407,7 +407,7 @@ func mockName(typeName *ast.Ident) string {
return fmt.Sprintf("Mock%v", typeName)
}

func (g *generator) GenerateMockInterface(typeName *ast.Ident, it *ast.InterfaceType) os.Error {
func (g *generator) GenerateMockInterface(typeName *ast.Ident, it *ast.InterfaceType) error {
mockType := mockName(typeName)

g.p("")
Expand Down Expand Up @@ -593,7 +593,7 @@ func (p *parameterList) typeString() string {
return strings.Join(p.t, ", ")
}

func (g *generator) GenerateMockMethod(mockType, methodName string, f *ast.FuncType) os.Error {
func (g *generator) GenerateMockMethod(mockType, methodName string, f *ast.FuncType) error {
args := flattenFieldList(f.Params)
rets := flattenFieldList(f.Results)

Expand Down Expand Up @@ -646,7 +646,7 @@ func isVariadic(f *ast.FuncType) bool {
return ok
}

func (g *generator) GenerateMockRecorderMethod(mockType, methodName string, f *ast.FuncType) os.Error {
func (g *generator) GenerateMockRecorderMethod(mockType, methodName string, f *ast.FuncType) error {
nargs, variadic := f.Params.NumFields(), isVariadic(f)
if variadic {
nargs--
Expand Down
5 changes: 2 additions & 3 deletions sample/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import "io"
import (
btz "bytes"
"hash"
"http"
"log"
"net"
"os"
"net/http"
)

// Dependencies outside the standard library.
Expand Down Expand Up @@ -42,7 +41,7 @@ type Index interface {
ForeignFour(imp_four.Imp4)

// A method that returns a nillable type.
NillableRet() os.Error
NillableRet() error

// A method with an ellipsis argument.
Ellip(fmt string, args ...interface{})
Expand Down

0 comments on commit 7d1b033

Please sign in to comment.