Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
G
getty
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
getty
Commits
52f81ec7
Commit
52f81ec7
authored
Aug 07, 2018
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add: test and add pb case
parent
6fcc015a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
845 additions
and
46 deletions
+845
-46
main.go
rpc/client/app/main.go
+27
-28
service.pb.go
rpc/proto/service.pb.go
+793
-10
service.proto
rpc/proto/service.proto
+17
-0
test.go
rpc/proto/test.go
+8
-8
No files found.
rpc/client/app/main.go
View file @
52f81ec7
...
@@ -109,70 +109,69 @@ func initSignal() {
...
@@ -109,70 +109,69 @@ func initSignal() {
}
}
func
testJSON
()
{
func
testJSON
()
{
ts
:=
rpc_examples
.
TestService
{}
testReq
:=
rpc_examples
.
TestReq
{
"aaa"
,
"bbb"
,
"ccc"
}
testReq
:=
rpc_examples
.
TestReq
{
"aaa"
,
"bbb"
,
"ccc"
}
testRsp
:=
rpc_examples
.
TestRsp
{}
testRsp
:=
rpc_examples
.
TestRsp
{}
err
:=
client
.
Call
(
rpc
.
CodecJson
,
"127.0.0.1:20000"
,
"TestService"
,
"Test"
,
&
testReq
,
&
testRsp
)
err
:=
client
.
Call
(
rpc
.
CodecJson
,
"127.0.0.1:20000"
,
ts
.
Service
()
,
"Test"
,
&
testReq
,
&
testRsp
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
"client.Call(TestService::Test) = error:%s"
,
jerrors
.
ErrorStack
(
err
))
log
.
Error
(
"client.Call(TestService::Test) = error:%s"
,
jerrors
.
ErrorStack
(
err
))
return
return
}
}
gxlog
.
CError
(
"TestService::Test(param:%#v) = res:%s"
,
testReq
,
testRsp
)
log
.
Info
(
"TestService::Test(param:%#v) = res:%s"
,
testReq
,
testRsp
)
return
addReq
:=
rpc_examples
.
AddReq
{
1
,
10
}
addRsp
:=
rpc_examples
.
AddRsp
{}
var
addResult
int
err
=
client
.
Call
(
rpc
.
CodecJson
,
"127.0.0.1:10000"
,
ts
.
Service
(),
"Add"
,
&
addReq
,
&
addRsp
)
err
=
client
.
Call
(
rpc
.
CodecJson
,
"127.0.0.1:10000"
,
"TestService"
,
"Add"
,
1
,
&
addResult
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
"client.Call(TestService::Add) = error:%s"
,
jerrors
.
ErrorStack
(
err
))
log
.
Error
(
"client.Call(TestService::Add) = error:%s"
,
jerrors
.
ErrorStack
(
err
))
return
return
}
}
log
.
Info
(
"TestService::Add(
1) = res:%d"
,
addResult
)
log
.
Info
(
"TestService::Add(
req:%#v) = res:%#v"
,
addReq
,
addRsp
)
var
errResult
int
errReq
:=
rpc_examples
.
ErrReq
{
1
}
err
=
client
.
Call
(
rpc
.
CodecJson
,
"127.0.0.1:10000"
,
"TestService"
,
"Err"
,
2
,
&
errResult
)
errRsp
:=
rpc_examples
.
ErrRsp
{}
err
=
client
.
Call
(
rpc
.
CodecJson
,
"127.0.0.1:20000"
,
ts
.
Service
(),
"Err"
,
&
errReq
,
&
errRsp
)
if
err
!=
nil
{
if
err
!=
nil
{
// error test case, this invocation should step into this branch.
// error test case, this invocation should step into this branch.
log
.
Error
(
"client.Call(TestService::Err) = error:%s"
,
jerrors
.
ErrorStack
(
err
))
log
.
Error
(
"client.Call(TestService::Err) = error:%s"
,
jerrors
.
ErrorStack
(
err
))
return
return
}
}
log
.
Info
(
"TestService::Err(
2) = res:%s"
,
errResult
)
log
.
Info
(
"TestService::Err(
req:%#v) = res:%s"
,
errReq
,
errRsp
)
}
}
func
testProtobuf
()
{
func
testProtobuf
()
{
ts
:=
rpc_examples
.
TestService
{}
testReq
:=
rpc_examples
.
TestReq
{
"aaa"
,
"bbb"
,
"ccc"
}
testReq
:=
rpc_examples
.
TestReq
{
"aaa"
,
"bbb"
,
"ccc"
}
testRsp
:=
rpc_examples
.
TestRsp
{}
testRsp
:=
rpc_examples
.
TestRsp
{}
err
:=
client
.
Call
(
rpc
.
CodecProtobuf
,
"127.0.0.1:20000"
,
"TestService"
,
"Test"
,
&
testReq
,
&
testRsp
)
err
:=
client
.
Call
(
rpc
.
CodecProtobuf
,
"127.0.0.1:20000"
,
ts
.
Service
()
,
"Test"
,
&
testReq
,
&
testRsp
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
"client.Call(TestService::Test) = error:%s"
,
jerrors
.
ErrorStack
(
err
))
log
.
Error
(
"client.Call(TestService::Test) = error:%s"
,
jerrors
.
ErrorStack
(
err
))
return
return
}
}
gxlog
.
CError
(
"TestService::Test(param:%#v) = res:%s"
,
testReq
,
testRsp
)
log
.
Info
(
"TestService::Test(param:%#v) = res:%s"
,
testReq
,
testRsp
)
addReq
:=
rpc_examples
.
AddReq
{
1
,
10
}
addRsp
:=
rpc_examples
.
AddRsp
{}
err
=
client
.
Call
(
rpc
.
CodecProtobuf
,
"127.0.0.1:10000"
,
ts
.
Service
(),
"Add"
,
&
addReq
,
&
addRsp
)
if
err
!=
nil
{
log
.
Error
(
"client.Call(TestService::Add) = error:%s"
,
jerrors
.
ErrorStack
(
err
))
return
return
}
log
.
Info
(
"TestService::Add(req:%#v) = res:%#v"
,
addReq
,
addRsp
)
// var addResult int
errReq
:=
rpc_examples
.
ErrReq
{
1
}
// err = client.Call(rpc.CodecProtobuf, "127.0.0.1:20000", "TestService", "Add", 1, &addResult)
errRsp
:=
rpc_examples
.
ErrRsp
{}
// if err != nil {
err
=
client
.
Call
(
rpc
.
CodecProtobuf
,
"127.0.0.1:20000"
,
ts
.
Service
(),
"Err"
,
&
errReq
,
&
errRsp
)
// log.Error("client.Call(TestService::Add) = error:%s", jerrors.ErrorStack(err))
// return
// }
// log.Info("TestService::Add(1) = res:%d", addResult)
var
errResult
int
err
=
client
.
Call
(
rpc
.
CodecProtobuf
,
"127.0.0.1:20000"
,
"TestService"
,
"Err"
,
2
,
&
errResult
)
if
err
!=
nil
{
if
err
!=
nil
{
// error test case, this invocation should step into this branch.
// error test case, this invocation should step into this branch.
log
.
Error
(
"client.Call(TestService::Err) = error:%s"
,
jerrors
.
ErrorStack
(
err
))
log
.
Error
(
"client.Call(TestService::Err) = error:%s"
,
jerrors
.
ErrorStack
(
err
))
return
return
}
}
log
.
Info
(
"TestService::Err(
2) = res:%s"
,
errResult
)
log
.
Info
(
"TestService::Err(
req:%#v) = res:%#v"
,
errReq
,
errRsp
)
}
}
func
test
()
{
func
test
()
{
gxlog
.
CInfo
(
"
\n
start to run json rpc example:"
)
testJSON
()
testJSON
()
time
.
Sleep
(
2e9
)
// testProtobuf()
gxlog
.
CInfo
(
"
\n
start to run protobuf rpc example:"
)
testProtobuf
()
}
}
rpc/proto/service.pb.go
View file @
52f81ec7
...
@@ -10,6 +10,10 @@
...
@@ -10,6 +10,10 @@
It has these top-level messages:
It has these top-level messages:
TestReq
TestReq
TestRsp
TestRsp
AddReq
AddRsp
ErrReq
ErrRsp
*/
*/
package
rpc_examples
package
rpc_examples
...
@@ -52,9 +56,46 @@ func (m *TestRsp) Reset() { *m = TestRsp{} }
...
@@ -52,9 +56,46 @@ func (m *TestRsp) Reset() { *m = TestRsp{} }
func
(
*
TestRsp
)
ProtoMessage
()
{}
func
(
*
TestRsp
)
ProtoMessage
()
{}
func
(
*
TestRsp
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptorService
,
[]
int
{
1
}
}
func
(
*
TestRsp
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptorService
,
[]
int
{
1
}
}
type
AddReq
struct
{
A
int32
`protobuf:"varint,1,opt,name=A" json:"A"`
B
int32
`protobuf:"varint,2,opt,name=B" json:"B"`
}
func
(
m
*
AddReq
)
Reset
()
{
*
m
=
AddReq
{}
}
func
(
*
AddReq
)
ProtoMessage
()
{}
func
(
*
AddReq
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptorService
,
[]
int
{
2
}
}
type
AddRsp
struct
{
Sum
int32
`protobuf:"varint,1,opt,name=Sum" json:"Sum"`
}
func
(
m
*
AddRsp
)
Reset
()
{
*
m
=
AddRsp
{}
}
func
(
*
AddRsp
)
ProtoMessage
()
{}
func
(
*
AddRsp
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptorService
,
[]
int
{
3
}
}
type
ErrReq
struct
{
A
int32
`protobuf:"varint,1,opt,name=A" json:"A"`
}
func
(
m
*
ErrReq
)
Reset
()
{
*
m
=
ErrReq
{}
}
func
(
*
ErrReq
)
ProtoMessage
()
{}
func
(
*
ErrReq
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptorService
,
[]
int
{
4
}
}
type
ErrRsp
struct
{
A
int32
`protobuf:"varint,1,opt,name=A" json:"A"`
}
func
(
m
*
ErrRsp
)
Reset
()
{
*
m
=
ErrRsp
{}
}
func
(
*
ErrRsp
)
ProtoMessage
()
{}
func
(
*
ErrRsp
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptorService
,
[]
int
{
5
}
}
func
init
()
{
func
init
()
{
proto
.
RegisterType
((
*
TestReq
)(
nil
),
"rpc_examples.TestReq"
)
proto
.
RegisterType
((
*
TestReq
)(
nil
),
"rpc_examples.TestReq"
)
proto
.
RegisterType
((
*
TestRsp
)(
nil
),
"rpc_examples.TestRsp"
)
proto
.
RegisterType
((
*
TestRsp
)(
nil
),
"rpc_examples.TestRsp"
)
proto
.
RegisterType
((
*
AddReq
)(
nil
),
"rpc_examples.AddReq"
)
proto
.
RegisterType
((
*
AddRsp
)(
nil
),
"rpc_examples.AddRsp"
)
proto
.
RegisterType
((
*
ErrReq
)(
nil
),
"rpc_examples.ErrReq"
)
proto
.
RegisterType
((
*
ErrRsp
)(
nil
),
"rpc_examples.ErrRsp"
)
}
}
func
(
this
*
TestReq
)
VerboseEqual
(
that
interface
{})
error
{
func
(
this
*
TestReq
)
VerboseEqual
(
that
interface
{})
error
{
if
that
==
nil
{
if
that
==
nil
{
...
@@ -188,6 +229,252 @@ func (this *TestRsp) Equal(that interface{}) bool {
...
@@ -188,6 +229,252 @@ func (this *TestRsp) Equal(that interface{}) bool {
}
}
return
true
return
true
}
}
func
(
this
*
AddReq
)
VerboseEqual
(
that
interface
{})
error
{
if
that
==
nil
{
if
this
==
nil
{
return
nil
}
return
fmt
.
Errorf
(
"that == nil && this != nil"
)
}
that1
,
ok
:=
that
.
(
*
AddReq
)
if
!
ok
{
that2
,
ok
:=
that
.
(
AddReq
)
if
ok
{
that1
=
&
that2
}
else
{
return
fmt
.
Errorf
(
"that is not of type *AddReq"
)
}
}
if
that1
==
nil
{
if
this
==
nil
{
return
nil
}
return
fmt
.
Errorf
(
"that is type *AddReq but is nil && this != nil"
)
}
else
if
this
==
nil
{
return
fmt
.
Errorf
(
"that is type *AddReq but is not nil && this == nil"
)
}
if
this
.
A
!=
that1
.
A
{
return
fmt
.
Errorf
(
"A this(%v) Not Equal that(%v)"
,
this
.
A
,
that1
.
A
)
}
if
this
.
B
!=
that1
.
B
{
return
fmt
.
Errorf
(
"B this(%v) Not Equal that(%v)"
,
this
.
B
,
that1
.
B
)
}
return
nil
}
func
(
this
*
AddReq
)
Equal
(
that
interface
{})
bool
{
if
that
==
nil
{
if
this
==
nil
{
return
true
}
return
false
}
that1
,
ok
:=
that
.
(
*
AddReq
)
if
!
ok
{
that2
,
ok
:=
that
.
(
AddReq
)
if
ok
{
that1
=
&
that2
}
else
{
return
false
}
}
if
that1
==
nil
{
if
this
==
nil
{
return
true
}
return
false
}
else
if
this
==
nil
{
return
false
}
if
this
.
A
!=
that1
.
A
{
return
false
}
if
this
.
B
!=
that1
.
B
{
return
false
}
return
true
}
func
(
this
*
AddRsp
)
VerboseEqual
(
that
interface
{})
error
{
if
that
==
nil
{
if
this
==
nil
{
return
nil
}
return
fmt
.
Errorf
(
"that == nil && this != nil"
)
}
that1
,
ok
:=
that
.
(
*
AddRsp
)
if
!
ok
{
that2
,
ok
:=
that
.
(
AddRsp
)
if
ok
{
that1
=
&
that2
}
else
{
return
fmt
.
Errorf
(
"that is not of type *AddRsp"
)
}
}
if
that1
==
nil
{
if
this
==
nil
{
return
nil
}
return
fmt
.
Errorf
(
"that is type *AddRsp but is nil && this != nil"
)
}
else
if
this
==
nil
{
return
fmt
.
Errorf
(
"that is type *AddRsp but is not nil && this == nil"
)
}
if
this
.
Sum
!=
that1
.
Sum
{
return
fmt
.
Errorf
(
"Sum this(%v) Not Equal that(%v)"
,
this
.
Sum
,
that1
.
Sum
)
}
return
nil
}
func
(
this
*
AddRsp
)
Equal
(
that
interface
{})
bool
{
if
that
==
nil
{
if
this
==
nil
{
return
true
}
return
false
}
that1
,
ok
:=
that
.
(
*
AddRsp
)
if
!
ok
{
that2
,
ok
:=
that
.
(
AddRsp
)
if
ok
{
that1
=
&
that2
}
else
{
return
false
}
}
if
that1
==
nil
{
if
this
==
nil
{
return
true
}
return
false
}
else
if
this
==
nil
{
return
false
}
if
this
.
Sum
!=
that1
.
Sum
{
return
false
}
return
true
}
func
(
this
*
ErrReq
)
VerboseEqual
(
that
interface
{})
error
{
if
that
==
nil
{
if
this
==
nil
{
return
nil
}
return
fmt
.
Errorf
(
"that == nil && this != nil"
)
}
that1
,
ok
:=
that
.
(
*
ErrReq
)
if
!
ok
{
that2
,
ok
:=
that
.
(
ErrReq
)
if
ok
{
that1
=
&
that2
}
else
{
return
fmt
.
Errorf
(
"that is not of type *ErrReq"
)
}
}
if
that1
==
nil
{
if
this
==
nil
{
return
nil
}
return
fmt
.
Errorf
(
"that is type *ErrReq but is nil && this != nil"
)
}
else
if
this
==
nil
{
return
fmt
.
Errorf
(
"that is type *ErrReq but is not nil && this == nil"
)
}
if
this
.
A
!=
that1
.
A
{
return
fmt
.
Errorf
(
"A this(%v) Not Equal that(%v)"
,
this
.
A
,
that1
.
A
)
}
return
nil
}
func
(
this
*
ErrReq
)
Equal
(
that
interface
{})
bool
{
if
that
==
nil
{
if
this
==
nil
{
return
true
}
return
false
}
that1
,
ok
:=
that
.
(
*
ErrReq
)
if
!
ok
{
that2
,
ok
:=
that
.
(
ErrReq
)
if
ok
{
that1
=
&
that2
}
else
{
return
false
}
}
if
that1
==
nil
{
if
this
==
nil
{
return
true
}
return
false
}
else
if
this
==
nil
{
return
false
}
if
this
.
A
!=
that1
.
A
{
return
false
}
return
true
}
func
(
this
*
ErrRsp
)
VerboseEqual
(
that
interface
{})
error
{
if
that
==
nil
{
if
this
==
nil
{
return
nil
}
return
fmt
.
Errorf
(
"that == nil && this != nil"
)
}
that1
,
ok
:=
that
.
(
*
ErrRsp
)
if
!
ok
{
that2
,
ok
:=
that
.
(
ErrRsp
)
if
ok
{
that1
=
&
that2
}
else
{
return
fmt
.
Errorf
(
"that is not of type *ErrRsp"
)
}
}
if
that1
==
nil
{
if
this
==
nil
{
return
nil
}
return
fmt
.
Errorf
(
"that is type *ErrRsp but is nil && this != nil"
)
}
else
if
this
==
nil
{
return
fmt
.
Errorf
(
"that is type *ErrRsp but is not nil && this == nil"
)
}
if
this
.
A
!=
that1
.
A
{
return
fmt
.
Errorf
(
"A this(%v) Not Equal that(%v)"
,
this
.
A
,
that1
.
A
)
}
return
nil
}
func
(
this
*
ErrRsp
)
Equal
(
that
interface
{})
bool
{
if
that
==
nil
{
if
this
==
nil
{
return
true
}
return
false
}
that1
,
ok
:=
that
.
(
*
ErrRsp
)
if
!
ok
{
that2
,
ok
:=
that
.
(
ErrRsp
)
if
ok
{
that1
=
&
that2
}
else
{
return
false
}
}
if
that1
==
nil
{
if
this
==
nil
{
return
true
}
return
false
}
else
if
this
==
nil
{
return
false
}
if
this
.
A
!=
that1
.
A
{
return
false
}
return
true
}
func
(
this
*
TestReq
)
GoString
()
string
{
func
(
this
*
TestReq
)
GoString
()
string
{
if
this
==
nil
{
if
this
==
nil
{
return
"nil"
return
"nil"
...
@@ -210,6 +497,47 @@ func (this *TestRsp) GoString() string {
...
@@ -210,6 +497,47 @@ func (this *TestRsp) GoString() string {
s
=
append
(
s
,
"}"
)
s
=
append
(
s
,
"}"
)
return
strings
.
Join
(
s
,
""
)
return
strings
.
Join
(
s
,
""
)
}
}
func
(
this
*
AddReq
)
GoString
()
string
{
if
this
==
nil
{
return
"nil"
}
s
:=
make
([]
string
,
0
,
6
)
s
=
append
(
s
,
"&rpc_examples.AddReq{"
)
s
=
append
(
s
,
"A: "
+
fmt
.
Sprintf
(
"%#v"
,
this
.
A
)
+
",
\n
"
)
s
=
append
(
s
,
"B: "
+
fmt
.
Sprintf
(
"%#v"
,
this
.
B
)
+
",
\n
"
)
s
=
append
(
s
,
"}"
)
return
strings
.
Join
(
s
,
""
)
}
func
(
this
*
AddRsp
)
GoString
()
string
{
if
this
==
nil
{
return
"nil"
}
s
:=
make
([]
string
,
0
,
5
)
s
=
append
(
s
,
"&rpc_examples.AddRsp{"
)
s
=
append
(
s
,
"Sum: "
+
fmt
.
Sprintf
(
"%#v"
,
this
.
Sum
)
+
",
\n
"
)
s
=
append
(
s
,
"}"
)
return
strings
.
Join
(
s
,
""
)
}
func
(
this
*
ErrReq
)
GoString
()
string
{
if
this
==
nil
{
return
"nil"
}
s
:=
make
([]
string
,
0
,
5
)
s
=
append
(
s
,
"&rpc_examples.ErrReq{"
)
s
=
append
(
s
,
"A: "
+
fmt
.
Sprintf
(
"%#v"
,
this
.
A
)
+
",
\n
"
)
s
=
append
(
s
,
"}"
)
return
strings
.
Join
(
s
,
""
)
}
func
(
this
*
ErrRsp
)
GoString
()
string
{
if
this
==
nil
{
return
"nil"
}
s
:=
make
([]
string
,
0
,
5
)
s
=
append
(
s
,
"&rpc_examples.ErrRsp{"
)
s
=
append
(
s
,
"A: "
+
fmt
.
Sprintf
(
"%#v"
,
this
.
A
)
+
",
\n
"
)
s
=
append
(
s
,
"}"
)
return
strings
.
Join
(
s
,
""
)
}
func
valueToGoStringService
(
v
interface
{},
typ
string
)
string
{
func
valueToGoStringService
(
v
interface
{},
typ
string
)
string
{
rv
:=
reflect
.
ValueOf
(
v
)
rv
:=
reflect
.
ValueOf
(
v
)
if
rv
.
IsNil
()
{
if
rv
.
IsNil
()
{
...
@@ -270,12 +598,99 @@ func (m *TestRsp) MarshalTo(dAtA []byte) (int, error) {
...
@@ -270,12 +598,99 @@ func (m *TestRsp) MarshalTo(dAtA []byte) (int, error) {
return
i
,
nil
return
i
,
nil
}
}
func
encodeFixed64Service
(
dAtA
[]
byte
,
offset
int
,
v
uint64
)
int
{
func
(
m
*
AddReq
)
Marshal
()
(
dAtA
[]
byte
,
err
error
)
{
dAtA
[
offset
]
=
uint8
(
v
)
size
:=
m
.
Size
()
dAtA
[
offset
+
1
]
=
uint8
(
v
>>
8
)
dAtA
=
make
([]
byte
,
size
)
dAtA
[
offset
+
2
]
=
uint8
(
v
>>
16
)
n
,
err
:=
m
.
MarshalTo
(
dAtA
)
dAtA
[
offset
+
3
]
=
uint8
(
v
>>
24
)
if
err
!=
nil
{
dAtA
[
offset
+
4
]
=
uint8
(
v
>>
32
)
return
nil
,
err
}
return
dAtA
[
:
n
],
nil
}
func
(
m
*
AddReq
)
MarshalTo
(
dAtA
[]
byte
)
(
int
,
error
)
{
var
i
int
_
=
i
var
l
int
_
=
l
dAtA
[
i
]
=
0x8
i
++
i
=
encodeVarintService
(
dAtA
,
i
,
uint64
(
m
.
A
))
dAtA
[
i
]
=
0x10
i
++
i
=
encodeVarintService
(
dAtA
,
i
,
uint64
(
m
.
B
))
return
i
,
nil
}
func
(
m
*
AddRsp
)
Marshal
()
(
dAtA
[]
byte
,
err
error
)
{
size
:=
m
.
Size
()
dAtA
=
make
([]
byte
,
size
)
n
,
err
:=
m
.
MarshalTo
(
dAtA
)
if
err
!=
nil
{
return
nil
,
err
}
return
dAtA
[
:
n
],
nil
}
func
(
m
*
AddRsp
)
MarshalTo
(
dAtA
[]
byte
)
(
int
,
error
)
{
var
i
int
_
=
i
var
l
int
_
=
l
dAtA
[
i
]
=
0x8
i
++
i
=
encodeVarintService
(
dAtA
,
i
,
uint64
(
m
.
Sum
))
return
i
,
nil
}
func
(
m
*
ErrReq
)
Marshal
()
(
dAtA
[]
byte
,
err
error
)
{
size
:=
m
.
Size
()
dAtA
=
make
([]
byte
,
size
)
n
,
err
:=
m
.
MarshalTo
(
dAtA
)
if
err
!=
nil
{
return
nil
,
err
}
return
dAtA
[
:
n
],
nil
}
func
(
m
*
ErrReq
)
MarshalTo
(
dAtA
[]
byte
)
(
int
,
error
)
{
var
i
int
_
=
i
var
l
int
_
=
l
dAtA
[
i
]
=
0x8
i
++
i
=
encodeVarintService
(
dAtA
,
i
,
uint64
(
m
.
A
))
return
i
,
nil
}
func
(
m
*
ErrRsp
)
Marshal
()
(
dAtA
[]
byte
,
err
error
)
{
size
:=
m
.
Size
()
dAtA
=
make
([]
byte
,
size
)
n
,
err
:=
m
.
MarshalTo
(
dAtA
)
if
err
!=
nil
{
return
nil
,
err
}
return
dAtA
[
:
n
],
nil
}
func
(
m
*
ErrRsp
)
MarshalTo
(
dAtA
[]
byte
)
(
int
,
error
)
{
var
i
int
_
=
i
var
l
int
_
=
l
dAtA
[
i
]
=
0x8
i
++
i
=
encodeVarintService
(
dAtA
,
i
,
uint64
(
m
.
A
))
return
i
,
nil
}
func
encodeFixed64Service
(
dAtA
[]
byte
,
offset
int
,
v
uint64
)
int
{
dAtA
[
offset
]
=
uint8
(
v
)
dAtA
[
offset
+
1
]
=
uint8
(
v
>>
8
)
dAtA
[
offset
+
2
]
=
uint8
(
v
>>
16
)
dAtA
[
offset
+
3
]
=
uint8
(
v
>>
24
)
dAtA
[
offset
+
4
]
=
uint8
(
v
>>
32
)
dAtA
[
offset
+
5
]
=
uint8
(
v
>>
40
)
dAtA
[
offset
+
5
]
=
uint8
(
v
>>
40
)
dAtA
[
offset
+
6
]
=
uint8
(
v
>>
48
)
dAtA
[
offset
+
6
]
=
uint8
(
v
>>
48
)
dAtA
[
offset
+
7
]
=
uint8
(
v
>>
56
)
dAtA
[
offset
+
7
]
=
uint8
(
v
>>
56
)
...
@@ -317,6 +732,35 @@ func (m *TestRsp) Size() (n int) {
...
@@ -317,6 +732,35 @@ func (m *TestRsp) Size() (n int) {
return
n
return
n
}
}
func
(
m
*
AddReq
)
Size
()
(
n
int
)
{
var
l
int
_
=
l
n
+=
1
+
sovService
(
uint64
(
m
.
A
))
n
+=
1
+
sovService
(
uint64
(
m
.
B
))
return
n
}
func
(
m
*
AddRsp
)
Size
()
(
n
int
)
{
var
l
int
_
=
l
n
+=
1
+
sovService
(
uint64
(
m
.
Sum
))
return
n
}
func
(
m
*
ErrReq
)
Size
()
(
n
int
)
{
var
l
int
_
=
l
n
+=
1
+
sovService
(
uint64
(
m
.
A
))
return
n
}
func
(
m
*
ErrRsp
)
Size
()
(
n
int
)
{
var
l
int
_
=
l
n
+=
1
+
sovService
(
uint64
(
m
.
A
))
return
n
}
func
sovService
(
x
uint64
)
(
n
int
)
{
func
sovService
(
x
uint64
)
(
n
int
)
{
for
{
for
{
n
++
n
++
...
@@ -352,6 +796,47 @@ func (this *TestRsp) String() string {
...
@@ -352,6 +796,47 @@ func (this *TestRsp) String() string {
},
""
)
},
""
)
return
s
return
s
}
}
func
(
this
*
AddReq
)
String
()
string
{
if
this
==
nil
{
return
"nil"
}
s
:=
strings
.
Join
([]
string
{
`&AddReq{`
,
`A:`
+
fmt
.
Sprintf
(
"%v"
,
this
.
A
)
+
`,`
,
`B:`
+
fmt
.
Sprintf
(
"%v"
,
this
.
B
)
+
`,`
,
`}`
,
},
""
)
return
s
}
func
(
this
*
AddRsp
)
String
()
string
{
if
this
==
nil
{
return
"nil"
}
s
:=
strings
.
Join
([]
string
{
`&AddRsp{`
,
`Sum:`
+
fmt
.
Sprintf
(
"%v"
,
this
.
Sum
)
+
`,`
,
`}`
,
},
""
)
return
s
}
func
(
this
*
ErrReq
)
String
()
string
{
if
this
==
nil
{
return
"nil"
}
s
:=
strings
.
Join
([]
string
{
`&ErrReq{`
,
`A:`
+
fmt
.
Sprintf
(
"%v"
,
this
.
A
)
+
`,`
,
`}`
,
},
""
)
return
s
}
func
(
this
*
ErrRsp
)
String
()
string
{
if
this
==
nil
{
return
"nil"
}
s
:=
strings
.
Join
([]
string
{
`&ErrRsp{`
,
`A:`
+
fmt
.
Sprintf
(
"%v"
,
this
.
A
)
+
`,`
,
`}`
,
},
""
)
return
s
}
func
valueToStringService
(
v
interface
{})
string
{
func
valueToStringService
(
v
interface
{})
string
{
rv
:=
reflect
.
ValueOf
(
v
)
rv
:=
reflect
.
ValueOf
(
v
)
if
rv
.
IsNil
()
{
if
rv
.
IsNil
()
{
...
@@ -576,6 +1061,301 @@ func (m *TestRsp) Unmarshal(dAtA []byte) error {
...
@@ -576,6 +1061,301 @@ func (m *TestRsp) Unmarshal(dAtA []byte) error {
}
}
return
nil
return
nil
}
}
func
(
m
*
AddReq
)
Unmarshal
(
dAtA
[]
byte
)
error
{
l
:=
len
(
dAtA
)
iNdEx
:=
0
for
iNdEx
<
l
{
preIndex
:=
iNdEx
var
wire
uint64
for
shift
:=
uint
(
0
);
;
shift
+=
7
{
if
shift
>=
64
{
return
ErrIntOverflowService
}
if
iNdEx
>=
l
{
return
io
.
ErrUnexpectedEOF
}
b
:=
dAtA
[
iNdEx
]
iNdEx
++
wire
|=
(
uint64
(
b
)
&
0x7F
)
<<
shift
if
b
<
0x80
{
break
}
}
fieldNum
:=
int32
(
wire
>>
3
)
wireType
:=
int
(
wire
&
0x7
)
if
wireType
==
4
{
return
fmt
.
Errorf
(
"proto: AddReq: wiretype end group for non-group"
)
}
if
fieldNum
<=
0
{
return
fmt
.
Errorf
(
"proto: AddReq: illegal tag %d (wire type %d)"
,
fieldNum
,
wire
)
}
switch
fieldNum
{
case
1
:
if
wireType
!=
0
{
return
fmt
.
Errorf
(
"proto: wrong wireType = %d for field A"
,
wireType
)
}
m
.
A
=
0
for
shift
:=
uint
(
0
);
;
shift
+=
7
{
if
shift
>=
64
{
return
ErrIntOverflowService
}
if
iNdEx
>=
l
{
return
io
.
ErrUnexpectedEOF
}
b
:=
dAtA
[
iNdEx
]
iNdEx
++
m
.
A
|=
(
int32
(
b
)
&
0x7F
)
<<
shift
if
b
<
0x80
{
break
}
}
case
2
:
if
wireType
!=
0
{
return
fmt
.
Errorf
(
"proto: wrong wireType = %d for field B"
,
wireType
)
}
m
.
B
=
0
for
shift
:=
uint
(
0
);
;
shift
+=
7
{
if
shift
>=
64
{
return
ErrIntOverflowService
}
if
iNdEx
>=
l
{
return
io
.
ErrUnexpectedEOF
}
b
:=
dAtA
[
iNdEx
]
iNdEx
++
m
.
B
|=
(
int32
(
b
)
&
0x7F
)
<<
shift
if
b
<
0x80
{
break
}
}
default
:
iNdEx
=
preIndex
skippy
,
err
:=
skipService
(
dAtA
[
iNdEx
:
])
if
err
!=
nil
{
return
err
}
if
skippy
<
0
{
return
ErrInvalidLengthService
}
if
(
iNdEx
+
skippy
)
>
l
{
return
io
.
ErrUnexpectedEOF
}
iNdEx
+=
skippy
}
}
if
iNdEx
>
l
{
return
io
.
ErrUnexpectedEOF
}
return
nil
}
func
(
m
*
AddRsp
)
Unmarshal
(
dAtA
[]
byte
)
error
{
l
:=
len
(
dAtA
)
iNdEx
:=
0
for
iNdEx
<
l
{
preIndex
:=
iNdEx
var
wire
uint64
for
shift
:=
uint
(
0
);
;
shift
+=
7
{
if
shift
>=
64
{
return
ErrIntOverflowService
}
if
iNdEx
>=
l
{
return
io
.
ErrUnexpectedEOF
}
b
:=
dAtA
[
iNdEx
]
iNdEx
++
wire
|=
(
uint64
(
b
)
&
0x7F
)
<<
shift
if
b
<
0x80
{
break
}
}
fieldNum
:=
int32
(
wire
>>
3
)
wireType
:=
int
(
wire
&
0x7
)
if
wireType
==
4
{
return
fmt
.
Errorf
(
"proto: AddRsp: wiretype end group for non-group"
)
}
if
fieldNum
<=
0
{
return
fmt
.
Errorf
(
"proto: AddRsp: illegal tag %d (wire type %d)"
,
fieldNum
,
wire
)
}
switch
fieldNum
{
case
1
:
if
wireType
!=
0
{
return
fmt
.
Errorf
(
"proto: wrong wireType = %d for field Sum"
,
wireType
)
}
m
.
Sum
=
0
for
shift
:=
uint
(
0
);
;
shift
+=
7
{
if
shift
>=
64
{
return
ErrIntOverflowService
}
if
iNdEx
>=
l
{
return
io
.
ErrUnexpectedEOF
}
b
:=
dAtA
[
iNdEx
]
iNdEx
++
m
.
Sum
|=
(
int32
(
b
)
&
0x7F
)
<<
shift
if
b
<
0x80
{
break
}
}
default
:
iNdEx
=
preIndex
skippy
,
err
:=
skipService
(
dAtA
[
iNdEx
:
])
if
err
!=
nil
{
return
err
}
if
skippy
<
0
{
return
ErrInvalidLengthService
}
if
(
iNdEx
+
skippy
)
>
l
{
return
io
.
ErrUnexpectedEOF
}
iNdEx
+=
skippy
}
}
if
iNdEx
>
l
{
return
io
.
ErrUnexpectedEOF
}
return
nil
}
func
(
m
*
ErrReq
)
Unmarshal
(
dAtA
[]
byte
)
error
{
l
:=
len
(
dAtA
)
iNdEx
:=
0
for
iNdEx
<
l
{
preIndex
:=
iNdEx
var
wire
uint64
for
shift
:=
uint
(
0
);
;
shift
+=
7
{
if
shift
>=
64
{
return
ErrIntOverflowService
}
if
iNdEx
>=
l
{
return
io
.
ErrUnexpectedEOF
}
b
:=
dAtA
[
iNdEx
]
iNdEx
++
wire
|=
(
uint64
(
b
)
&
0x7F
)
<<
shift
if
b
<
0x80
{
break
}
}
fieldNum
:=
int32
(
wire
>>
3
)
wireType
:=
int
(
wire
&
0x7
)
if
wireType
==
4
{
return
fmt
.
Errorf
(
"proto: ErrReq: wiretype end group for non-group"
)
}
if
fieldNum
<=
0
{
return
fmt
.
Errorf
(
"proto: ErrReq: illegal tag %d (wire type %d)"
,
fieldNum
,
wire
)
}
switch
fieldNum
{
case
1
:
if
wireType
!=
0
{
return
fmt
.
Errorf
(
"proto: wrong wireType = %d for field A"
,
wireType
)
}
m
.
A
=
0
for
shift
:=
uint
(
0
);
;
shift
+=
7
{
if
shift
>=
64
{
return
ErrIntOverflowService
}
if
iNdEx
>=
l
{
return
io
.
ErrUnexpectedEOF
}
b
:=
dAtA
[
iNdEx
]
iNdEx
++
m
.
A
|=
(
int32
(
b
)
&
0x7F
)
<<
shift
if
b
<
0x80
{
break
}
}
default
:
iNdEx
=
preIndex
skippy
,
err
:=
skipService
(
dAtA
[
iNdEx
:
])
if
err
!=
nil
{
return
err
}
if
skippy
<
0
{
return
ErrInvalidLengthService
}
if
(
iNdEx
+
skippy
)
>
l
{
return
io
.
ErrUnexpectedEOF
}
iNdEx
+=
skippy
}
}
if
iNdEx
>
l
{
return
io
.
ErrUnexpectedEOF
}
return
nil
}
func
(
m
*
ErrRsp
)
Unmarshal
(
dAtA
[]
byte
)
error
{
l
:=
len
(
dAtA
)
iNdEx
:=
0
for
iNdEx
<
l
{
preIndex
:=
iNdEx
var
wire
uint64
for
shift
:=
uint
(
0
);
;
shift
+=
7
{
if
shift
>=
64
{
return
ErrIntOverflowService
}
if
iNdEx
>=
l
{
return
io
.
ErrUnexpectedEOF
}
b
:=
dAtA
[
iNdEx
]
iNdEx
++
wire
|=
(
uint64
(
b
)
&
0x7F
)
<<
shift
if
b
<
0x80
{
break
}
}
fieldNum
:=
int32
(
wire
>>
3
)
wireType
:=
int
(
wire
&
0x7
)
if
wireType
==
4
{
return
fmt
.
Errorf
(
"proto: ErrRsp: wiretype end group for non-group"
)
}
if
fieldNum
<=
0
{
return
fmt
.
Errorf
(
"proto: ErrRsp: illegal tag %d (wire type %d)"
,
fieldNum
,
wire
)
}
switch
fieldNum
{
case
1
:
if
wireType
!=
0
{
return
fmt
.
Errorf
(
"proto: wrong wireType = %d for field A"
,
wireType
)
}
m
.
A
=
0
for
shift
:=
uint
(
0
);
;
shift
+=
7
{
if
shift
>=
64
{
return
ErrIntOverflowService
}
if
iNdEx
>=
l
{
return
io
.
ErrUnexpectedEOF
}
b
:=
dAtA
[
iNdEx
]
iNdEx
++
m
.
A
|=
(
int32
(
b
)
&
0x7F
)
<<
shift
if
b
<
0x80
{
break
}
}
default
:
iNdEx
=
preIndex
skippy
,
err
:=
skipService
(
dAtA
[
iNdEx
:
])
if
err
!=
nil
{
return
err
}
if
skippy
<
0
{
return
ErrInvalidLengthService
}
if
(
iNdEx
+
skippy
)
>
l
{
return
io
.
ErrUnexpectedEOF
}
iNdEx
+=
skippy
}
}
if
iNdEx
>
l
{
return
io
.
ErrUnexpectedEOF
}
return
nil
}
func
skipService
(
dAtA
[]
byte
)
(
n
int
,
err
error
)
{
func
skipService
(
dAtA
[]
byte
)
(
n
int
,
err
error
)
{
l
:=
len
(
dAtA
)
l
:=
len
(
dAtA
)
iNdEx
:=
0
iNdEx
:=
0
...
@@ -684,7 +1464,7 @@ var (
...
@@ -684,7 +1464,7 @@ var (
func
init
()
{
proto
.
RegisterFile
(
"service.proto"
,
fileDescriptorService
)
}
func
init
()
{
proto
.
RegisterFile
(
"service.proto"
,
fileDescriptorService
)
}
var
fileDescriptorService
=
[]
byte
{
var
fileDescriptorService
=
[]
byte
{
//
196
bytes of a gzipped FileDescriptorProto
//
244
bytes of a gzipped FileDescriptorProto
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0xff
,
0xe2
,
0xe2
,
0x2d
,
0x4e
,
0x2d
,
0x2a
,
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0xff
,
0xe2
,
0xe2
,
0x2d
,
0x4e
,
0x2d
,
0x2a
,
0xcb
,
0x4c
,
0x4e
,
0xd5
,
0x2b
,
0x28
,
0xca
,
0x2f
,
0xc9
,
0x17
,
0xe2
,
0x29
,
0x2a
,
0x48
,
0x8e
,
0x4f
,
0xcb
,
0x4c
,
0x4e
,
0xd5
,
0x2b
,
0x28
,
0xca
,
0x2f
,
0xc9
,
0x17
,
0xe2
,
0x29
,
0x2a
,
0x48
,
0x8e
,
0x4f
,
0xad
,
0x48
,
0xcc
,
0x2d
,
0xc8
,
0x49
,
0x2d
,
0x96
,
0xd2
,
0x4d
,
0xcf
,
0x2c
,
0xc9
,
0x28
,
0x4d
,
0xd2
,
0xad
,
0x48
,
0xcc
,
0x2d
,
0xc8
,
0x49
,
0x2d
,
0x96
,
0xd2
,
0x4d
,
0xcf
,
0x2c
,
0xc9
,
0x28
,
0x4d
,
0xd2
,
...
@@ -692,10 +1472,13 @@ var fileDescriptorService = []byte{
...
@@ -692,10 +1472,13 @@ var fileDescriptorService = []byte{
0xc0
,
0x1c
,
0x30
,
0x0b
,
0xa2
,
0x59
,
0xc9
,
0x95
,
0x8b
,
0x3d
,
0x24
,
0xb5
,
0xb8
,
0x24
,
0x28
,
0xb5
,
0xc0
,
0x1c
,
0x30
,
0x0b
,
0xa2
,
0x59
,
0xc9
,
0x95
,
0x8b
,
0x3d
,
0x24
,
0xb5
,
0xb8
,
0x24
,
0x28
,
0xb5
,
0x50
,
0x48
,
0x88
,
0x8b
,
0xd1
,
0x51
,
0x82
,
0x51
,
0x81
,
0x51
,
0x83
,
0xd3
,
0x89
,
0xe5
,
0xc4
,
0x3d
,
0x50
,
0x48
,
0x88
,
0x8b
,
0xd1
,
0x51
,
0x82
,
0x51
,
0x81
,
0x51
,
0x83
,
0xd3
,
0x89
,
0xe5
,
0xc4
,
0x3d
,
0x79
,
0x86
,
0x20
,
0x46
,
0x47
,
0x90
,
0x98
,
0x93
,
0x04
,
0x13
,
0xb2
,
0x98
,
0x13
,
0x48
,
0xcc
,
0x59
,
0x79
,
0x86
,
0x20
,
0x46
,
0x47
,
0x90
,
0x98
,
0x93
,
0x04
,
0x13
,
0xb2
,
0x98
,
0x13
,
0x48
,
0xcc
,
0x59
,
0x82
,
0x19
,
0x59
,
0xcc
,
0x59
,
0x49
,
0x16
,
0x6a
,
0x4c
,
0x71
,
0x01
,
0x36
,
0x63
,
0x9c
,
0x4c
,
0x4e
,
0x82
,
0x19
,
0x59
,
0xcc
,
0x59
,
0x49
,
0x16
,
0x6a
,
0x4c
,
0x71
,
0x01
,
0x36
,
0x63
,
0x94
,
0x0c
,
0xb8
,
0xd8
,
0x1c
,
0x53
,
0x52
,
0x50
,
0x2c
,
0x61
,
0xc5
,
0x62
,
0x09
,
0x5c
,
0xcc
,
0x49
,
0x49
,
0x01
,
0xa2
,
0xa3
,
0xb8
,
0x40
,
0x48
,
0x8c
,
0x8b
,
0x39
,
0xb8
,
0x34
,
0x17
,
0x45
,
0x0f
,
0x48
,
0x40
,
0x49
,
0x86
,
0x8b
,
0xcd
,
0xb5
,
0xa8
,
0x08
,
0x87
,
0x99
,
0x30
,
0x59
,
0x64
,
0xf7
,
0x20
,
0x64
,
0x9d
,
0x4c
,
0x4e
,
0x3c
,
0x94
,
0x63
,
0xb8
,
0xf0
,
0x50
,
0x8e
,
0xe1
,
0xc6
,
0x43
,
0x39
,
0x86
,
0x07
,
0x0f
,
0xe5
,
0x18
,
0x3c
,
0x94
,
0x63
,
0xb8
,
0xf0
,
0x50
,
0x8e
,
0xe1
,
0xc6
,
0x43
,
0x39
,
0x86
,
0x07
,
0x0f
,
0xe5
,
0x18
,
0x3f
,
0x3c
,
0x94
,
0x63
,
0x6c
,
0x78
,
0x24
,
0xc7
,
0xb8
,
0xe2
,
0x91
,
0x1c
,
0xe3
,
0x89
,
0x47
,
0x72
,
0x3f
,
0x3c
,
0x94
,
0x63
,
0x6c
,
0x78
,
0x24
,
0xc7
,
0xb8
,
0xe2
,
0x91
,
0x1c
,
0xe3
,
0x89
,
0x47
,
0x72
,
0x8c
,
0x17
,
0x1e
,
0xc9
,
0x31
,
0x3e
,
0x78
,
0x24
,
0xc7
,
0xf8
,
0xe2
,
0x91
,
0x1c
,
0xc3
,
0x87
,
0x47
,
0x8c
,
0x17
,
0x1e
,
0xc9
,
0x31
,
0x3e
,
0x78
,
0x24
,
0xc7
,
0xf8
,
0xe2
,
0x91
,
0x1c
,
0xc3
,
0x87
,
0x47
,
0x72
,
0x8c
,
0x13
,
0x1e
,
0xcb
,
0x31
,
0x00
,
0x02
,
0x00
,
0x00
,
0xff
,
0xff
,
0x
40
,
0xb0
,
0x81
,
0x1
6
,
0x72
,
0x8c
,
0x13
,
0x1e
,
0xcb
,
0x31
,
0x00
,
0x02
,
0x00
,
0x00
,
0xff
,
0xff
,
0x
93
,
0x7b
,
0x45
,
0x2
6
,
0x
e8
,
0x00
,
0x00
,
0x00
,
0x
78
,
0x01
,
0x00
,
0x00
,
}
}
rpc/proto/service.proto
View file @
52f81ec7
...
@@ -33,3 +33,20 @@ message TestReq {
...
@@ -33,3 +33,20 @@ message TestReq {
message
TestRsp
{
message
TestRsp
{
optional
string
A
=
1
[(
gogoproto.nullable
)
=
false
];
optional
string
A
=
1
[(
gogoproto.nullable
)
=
false
];
}
}
message
AddReq
{
optional
int32
A
=
1
[(
gogoproto.nullable
)
=
false
];
optional
int32
B
=
2
[(
gogoproto.nullable
)
=
false
];
}
message
AddRsp
{
optional
int32
Sum
=
1
[(
gogoproto.nullable
)
=
false
];
}
message
ErrReq
{
optional
int32
A
=
1
[(
gogoproto.nullable
)
=
false
];
}
message
ErrRsp
{
optional
int32
A
=
1
[(
gogoproto.nullable
)
=
false
];
}
\ No newline at end of file
rpc/proto/test.go
View file @
52f81ec7
package
rpc_examples
package
rpc_examples
import
(
import
(
"errors"
jerrors
"github.com/juju/errors"
// "errors"
)
)
type
TestService
struct
{
type
TestService
struct
{
...
@@ -16,17 +17,16 @@ func (r *TestService) Version() string {
...
@@ -16,17 +17,16 @@ func (r *TestService) Version() string {
return
"v1.0"
return
"v1.0"
}
}
func
(
r
*
TestService
)
Test
(
arg
TestReq
,
rsp
*
TestRsp
)
error
{
func
(
r
*
TestService
)
Test
(
req
*
TestReq
,
rsp
*
TestRsp
)
error
{
rsp
.
A
=
arg
.
A
+
", "
+
arg
.
B
+
", "
+
arg
.
C
rsp
.
A
=
req
.
A
+
", "
+
req
.
B
+
", "
+
req
.
C
return
nil
return
nil
}
}
func
(
r
*
TestService
)
Add
(
n
int
,
res
*
int
)
error
{
func
(
r
*
TestService
)
Add
(
req
*
AddReq
,
rsp
*
AddRsp
)
error
{
r
.
i
+=
n
rsp
.
Sum
=
req
.
A
+
req
.
B
*
res
=
r
.
i
+
100
return
nil
return
nil
}
}
func
(
r
*
TestService
)
Err
(
n
int
,
res
*
int
)
error
{
func
(
r
*
TestService
)
Err
(
req
*
ErrReq
,
rsp
*
ErrRsp
)
error
{
return
errors
.
New
(
"this is a error test"
)
return
j
errors
.
New
(
"this is a error test"
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment