Use any instead of interface{}

Signed-off-by: chenyahui <cyhone@qq.com>
This commit is contained in:
chenyahui
2023-09-17 17:41:58 +08:00
parent fb8a315be6
commit c0aa3b613b
61 changed files with 227 additions and 227 deletions

View File

@ -96,15 +96,15 @@ func (cs *chanClientStream) CloseSend() error {
// chanStream implements grpc.Stream using channels
type chanStream struct {
recvc <-chan interface{}
sendc chan<- interface{}
recvc <-chan any
sendc chan<- any
ctx context.Context
cancel context.CancelFunc
}
func (s *chanStream) Context() context.Context { return s.ctx }
func (s *chanStream) SendMsg(m interface{}) error {
func (s *chanStream) SendMsg(m any) error {
select {
case s.sendc <- m:
if err, ok := m.(error); ok {
@ -116,8 +116,8 @@ func (s *chanStream) SendMsg(m interface{}) error {
return s.ctx.Err()
}
func (s *chanStream) RecvMsg(m interface{}) error {
v := m.(*interface{})
func (s *chanStream) RecvMsg(m any) error {
v := m.(*any)
for {
select {
case msg, ok := <-s.recvc:
@ -141,7 +141,7 @@ func (s *chanStream) RecvMsg(m interface{}) error {
func newPipeStream(ctx context.Context, ssHandler func(chanServerStream) error) chanClientStream {
// ch1 is buffered so server can send error on close
ch1, ch2 := make(chan interface{}, 1), make(chan interface{})
ch1, ch2 := make(chan any, 1), make(chan any)
headerc, trailerc := make(chan metadata.MD, 1), make(chan metadata.MD, 1)
cctx, ccancel := context.WithCancel(ctx)