From 313d6a300f002b0e7f6c7dd4e09e954a69722bc9 Mon Sep 17 00:00:00 2001 From: David Symonds Date: Tue, 24 Jul 2012 13:19:07 +1000 Subject: [PATCH] Hack to work around a compiler bug in the reflection data of byte. --- mockgen/model/model.go | 8 ++++++++ sample/mock_user/mock_user.go | 8 ++++---- sample/user.go | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/mockgen/model/model.go b/mockgen/model/model.go index 58da353..87f96d5 100644 --- a/mockgen/model/model.go +++ b/mockgen/model/model.go @@ -333,7 +333,15 @@ func parameterFromType(t reflect.Type) (*Parameter, error) { var errorType = reflect.TypeOf((*error)(nil)).Elem() +var byteType = reflect.TypeOf(byte(0)) + func typeFromType(t reflect.Type) (Type, error) { + // Hack workaround for http://code.google.com/p/go/issues/detail?id=3853. + // This explicit check should not be necessary. + if t == byteType { + return PredeclaredType("byte"), nil + } + if imp := t.PkgPath(); imp != "" { return &NamedType{ Package: imp, diff --git a/sample/mock_user/mock_user.go b/sample/mock_user/mock_user.go index 8e3f03f..03576d8 100644 --- a/sample/mock_user/mock_user.go +++ b/sample/mock_user/mock_user.go @@ -193,14 +193,14 @@ func (_mr *_MockIndexRecorder) Put(arg0, arg1 interface{}) *gomock.Call { return _mr.mock.ctrl.RecordCall(_mr.mock, "Put", arg0, arg1) } -func (_m *MockIndex) Slice(_param0 []int) [3]int { - ret := _m.ctrl.Call(_m, "Slice", _param0) +func (_m *MockIndex) Slice(_param0 []int, _param1 []byte) [3]int { + ret := _m.ctrl.Call(_m, "Slice", _param0, _param1) ret0, _ := ret[0].([3]int) return ret0 } -func (_mr *_MockIndexRecorder) Slice(arg0 interface{}) *gomock.Call { - return _mr.mock.ctrl.RecordCall(_mr.mock, "Slice", arg0) +func (_mr *_MockIndexRecorder) Slice(arg0, arg1 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "Slice", arg0, arg1) } func (_m *MockIndex) Summary(_param0 *bytes.Buffer, _param1 io.Writer) { diff --git a/sample/user.go b/sample/user.go index c352e03..be36281 100644 --- a/sample/user.go +++ b/sample/user.go @@ -53,7 +53,7 @@ type Index interface { Ptr(arg *int) // A method with a slice argument and an array return. - Slice(a []int) [3]int + Slice(a []int, b []byte) [3]int // A method with channel arguments. Chan(a chan int, b chan<- hash.Hash)