github.heygears.com/openimsdk/tools@v0.0.49/a2r/option.go (about)

     1  package a2r
     2  
     3  import (
     4  	"context"
     5  	"github.com/openimsdk/tools/mw"
     6  	"google.golang.org/grpc"
     7  )
     8  
     9  func NewNilReplaceOption[A, B, C any](_ func(client C, ctx context.Context, req *A, options ...grpc.CallOption) (*B, error)) *Option[A, B] {
    10  	return &Option[A, B]{
    11  		RespAfter: respNilReplace[B],
    12  	}
    13  }
    14  
    15  // respNilReplace replaces nil maps and slices in the resp object and initializing them.
    16  func respNilReplace[T any](data *T) error {
    17  	mw.ReplaceNil(data)
    18  	return nil
    19  }
    20  
    21  // ------------------------------------------------------------------------------------------------------------------