ronantakizawa/codereview-bench huggingface dataset:
Repository: cli/cli
File: pkg/cmd/pr/edit/edit.go (Go)

Code before:
		return err
	}

	fmt.Fprintln(opts.IO.Out, pr.URL)

	return nil
}

func assigneeSearchFunc(apiClient *api.Client, repo ghrepo.Interface, editable *shared.Editable, assignableID string) func(string) prompter.MultiSelectSearchResult {
	searchFunc := func(input string) prompter.MultiSelectSearchResult {
		actors, err := api.SuggestedAssignableActors(
			apiClient,
			repo,
			assignableID,
			input)
		if err != nil {
			return prompter.MultiSelectSearchResult{
				Keys:        nil,
				Labels:      nil,
				MoreResults: 0,
				Err:         err,
			}
		}

		var logins []string
		var displayNames []string

		for _, a := range actors {
			if a.Login() != "" {
				logins = append(logins, a.Login())
			} else {
				continue
			}

			if a.DisplayName() != "" {
				displayNames = append(displayNames, a.DisplayName())
			} else {
				displayNames = append(displayNames, a.Login())
			}

			// Update the assignable actors metadata in the editable struct
			// so that updating the PR later can resolve the actor ID.
			editable.Metadata.AssignableActors = append(editable.Metadata.AssignableActors, a)
		}
		return prompter.MultiSelectSearchResult{
			Keys:        logins,
			Labels:      displayNames,
			MoreResults: 0,
			Err:         nil,
		}
	}

Review comment (suggestion):
**nitpick:** we can `make` these in advance:


```suggestion
		logins := make([]string, 0, len(actors))
		displayNames := make([]string, 0, len(actors))
```

Code after:
		return err
	}

	fmt.Fprintln(opts.IO.Out, pr.URL)

	return nil
}

func assigneeSearchFunc(apiClient *api.Client, repo ghrepo.Interface, editable *shared.Editable, assignableID string) func(string) prompter.MultiSelectSearchResult {
	searchFunc := func(input string) prompter.MultiSelectSearchResult {
		actors, err := api.SuggestedAssignableActors(
			apiClient,
			repo,
			assignableID,
			input)
		if err != nil {
			return prompter.MultiSelectSearchResult{
				Keys:        nil,
				Labels:      nil,
				MoreResults: 0,
				Err:         err,
			}
		}

		logins := make([]string, 0, len(actors))
		displayNames := make([]string, 0, len(actors))

		for _, a := range actors {
			if a.Login() != "" {
				logins = append(logins, a.Login())
			} else {
				continue
			}

			if a.DisplayName() != "" {
				displayNames = append(displayNames, a.DisplayName())
			} else {
				displayNames = append(displayNames, a.Login())
			}

			// Update the assignable actors metadata in the editable struct
			// so that updating the PR later can resolve the actor ID.
			editable.Metadata.AssignableActors = append(editable.Metadata.AssignableActors, a)
		}
		return prompter.MultiSelectSearchResult{
			Keys:        logins,
			Labels:      displayNames,
			MoreResults: 0,
			Err:         nil,
		}
	}
Repository: cli/cli
File: pkg/cmd/pr/edit/edit.go (Go)

Code before:
				Keys:        nil,
				Labels:      nil,
				MoreResults: 0,
				Err:         err,
			}
		}

		var logins []string
		var displayNames []string

		for _, a := range actors {
			if a.Login() != "" {
				logins = append(logins, a.Login())
			} else {
				continue
			}

			if a.DisplayName() != "" {
				displayNames = append(displayNames, a.DisplayName())
			} else {
				displayNames = append(displayNames, a.Login())
			}

			// Update the assignable actors metadata in the editable struct
			// so that updating the PR later can resolve the actor ID.
			editable.Metadata.AssignableActors = append(editable.Metadata.AssignableActors, a)
		}
		return prompter.MultiSelectSearchResult{
			Keys:        logins,
			Labels:      displayNames,
			MoreResults: 0,
			Err:         nil,
		}
	}
	return searchFunc
}

func updatePullRequest(httpClient *http.Client, repo ghrepo.Interface, id string, number int, editable shared.Editable) error {
	var wg errgroup.Group
	wg.Go(func() error {
		return shared.UpdateIssue(httpClient, repo, id, true, editable)
	})
	if editable.Reviewers.Edited {
		wg.Go(func() error {
			return updatePullRequestReviews(httpClient, repo, number, editable)
		})
	}
	return wg.Wait()
}

func updatePullRequestReviews(httpClient *http.Client, repo ghrepo.Interface, number int, editable shared.Editable) error {

Review comment (suggestion):
Shouldn't we check for existing actor before adding them? I mean, I don't know how the other part of the command handles dups, and it's easier to provide them a clean slice.

Code after:
				Keys:        nil,
				Labels:      nil,
				MoreResults: 0,
				Err:         err,
			}
		}

		logins := make([]string, 0, len(actors))
		displayNames := make([]string, 0, len(actors))

		for _, a := range actors {
			if a.Login() != "" {
				logins = append(logins, a.Login())
			} else {
				continue
			}

			if a.DisplayName() != "" {
				displayNames = append(displayNames, a.DisplayName())
			} else {
				displayNames = append(displayNames, a.Login())
			}

			// Update the assignable actors metadata in the editable struct
			// so that updating the PR later can resolve the actor ID.
			editable.Metadata.AssignableActors = append(editable.Metadata.AssignableActors, a)
		}
		return prompter.MultiSelectSearchResult{
			Keys:        logins,
			Labels:      displayNames,
			MoreResults: 0,
			Err:         nil,
		}
	}
	return searchFunc
}

func updatePullRequest(httpClient *http.Client, repo ghrepo.Interface, id string, number int, editable shared.Editable) error {
	var wg errgroup.Group
	wg.Go(func() error {
		return shared.UpdateIssue(httpClient, repo, id, true, editable)
	})
	if editable.Reviewers.Edited {
		wg.Go(func() error {
			return updatePullRequestReviews(httpClient, repo, number, editable)
		})
	}
	return wg.Wait()
}

func updatePullRequestReviews(httpClient *http.Client, repo ghrepo.Interface, number int, editable shared.Editable) error {
Repository: cloudwego/kitex
File: client/option_advanced.go (Go)

Code before:
		if callback == nil {
			panic("invalid Close Callback: nil")
		}
		o.CloseCallbacks = append(o.CloseCallbacks, callback)
	}}
}

// WithErrorHandler sets the error handler.
func WithErrorHandler(f func(error) error) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		o.Once.OnceOrPanic()
		di.Push(fmt.Sprintf("WithErrorHandler(%+v)", utils.GetFuncName(f)))

		o.ErrHandle = f
	}}
}

// WithBoundHandler adds remote.BoundHandler for client.
func WithBoundHandler(h remote.BoundHandler) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("AddBoundHandler(%T)", h))

		existInbound := false
		existOutbound := false
		for _, inboundHandler := range o.RemoteOpt.Inbounds {
			if inboundHandler == h.(remote.InboundHandler) {
				existInbound = true
				break
			}
		}
		for _, outboundHandler := range o.RemoteOpt.Outbounds {
			if outboundHandler == h.(remote.OutboundHandler) {
				existOutbound = true
				break
			}
		}
		// prevent duplication
		if !existInbound && !existOutbound {
			o.RemoteOpt.AppendBoundHandler(h)
		}
	}}
}


Review comment (suggestion):
It seems you didn't judge whether it's ok to assert h to remote.InboundHandler?
Actually don't need to check both Inbounds and Outbounds, if h implements remote.InboundHandler, check whether there's a same one, and remote.OutboundHandler is the same.

Code after:

		if callback == nil {
			panic("invalid Close Callback: nil")
		}
		o.CloseCallbacks = append(o.CloseCallbacks, callback)
	}}
}

// WithErrorHandler sets the error handler.
func WithErrorHandler(f func(error) error) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		o.Once.OnceOrPanic()
		di.Push(fmt.Sprintf("WithErrorHandler(%+v)", utils.GetFuncName(f)))

		o.ErrHandle = f
	}}
}

// WithBoundHandler adds remote.BoundHandler for client.
func WithBoundHandler(h remote.BoundHandler) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("AddBoundHandler(%T)", h))

		exist := false
		switch handler := h.(type) {
		case remote.InboundHandler:
			for _, inboundHandler := range o.RemoteOpt.Inbounds {
				if reflect.DeepEqual(inboundHandler, handler) {
					exist = true
					break
				}
			}
		case remote.OutboundHandler:
			for _, outboundHandler := range o.RemoteOpt.Outbounds {
				if reflect.DeepEqual(outboundHandler, handler) {
					exist = true
					break
				}
			}
		}
		// prevent duplication
		if !exist {
			o.RemoteOpt.AppendBoundHandler(h)
		}
	}}
}
Repository: cloudwego/kitex
File: client/option_advanced.go (Go)

Code before:
			panic("invalid Close Callback: nil")
		}
		o.CloseCallbacks = append(o.CloseCallbacks, callback)
	}}
}

// WithErrorHandler sets the error handler.
func WithErrorHandler(f func(error) error) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		o.Once.OnceOrPanic()
		di.Push(fmt.Sprintf("WithErrorHandler(%+v)", utils.GetFuncName(f)))

		o.ErrHandle = f
	}}
}

// WithBoundHandler adds remote.BoundHandler for client.
func WithBoundHandler(h remote.BoundHandler) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("AddBoundHandler(%T)", h))

		exist := false
		switch h.(type) {
		case remote.InboundHandler:
			for _, inboundHandler := range o.RemoteOpt.Inbounds {
				if inboundHandler == h.(remote.InboundHandler) {
					exist = true
					break
				}
			}
		case remote.OutboundHandler:
			for _, outboundHandler := range o.RemoteOpt.Outbounds {
				if outboundHandler == h.(remote.OutboundHandler) {
					exist = true
					break
				}
			}
		case remote.DuplexBoundHandler:
			for _, duplexboundHandler := range o.RemoteOpt.Inbounds {
				if duplexboundHandler == h.(remote.DuplexBoundHandler) {
					exist = true
					break
				}
			}
		}
		// prevent duplication
		if !exist {
			o.RemoteOpt.AppendBoundHandler(h)
		}
	}}
}

Review comment (suggestion):
`switch handler := h.(type)`
then just use handler instead of h.(remote.InboundHandler)

Code after:
		if callback == nil {
			panic("invalid Close Callback: nil")
		}
		o.CloseCallbacks = append(o.CloseCallbacks, callback)
	}}
}

// WithErrorHandler sets the error handler.
func WithErrorHandler(f func(error) error) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		o.Once.OnceOrPanic()
		di.Push(fmt.Sprintf("WithErrorHandler(%+v)", utils.GetFuncName(f)))

		o.ErrHandle = f
	}}
}

// WithBoundHandler adds remote.BoundHandler for client.
func WithBoundHandler(h remote.BoundHandler) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("AddBoundHandler(%T)", h))

		exist := false
		switch handler := h.(type) {
		case remote.InboundHandler:
			for _, inboundHandler := range o.RemoteOpt.Inbounds {
				if reflect.DeepEqual(inboundHandler, handler) {
					exist = true
					break
				}
			}
		case remote.OutboundHandler:
			for _, outboundHandler := range o.RemoteOpt.Outbounds {
				if reflect.DeepEqual(outboundHandler, handler) {
					exist = true
					break
				}
			}
		}
		// prevent duplication
		if !exist {
			o.RemoteOpt.AppendBoundHandler(h)
		}
	}}
}
Repository: cloudwego/kitex
File: client/option_advanced.go (Go)

Code before:
	}}
}

// WithBoundHandler adds remote.BoundHandler for client.
func WithBoundHandler(h remote.BoundHandler) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("AddBoundHandler(%T)", h))

		exist := false
		switch h.(type) {
		case remote.InboundHandler:
			for _, inboundHandler := range o.RemoteOpt.Inbounds {
				if inboundHandler == h.(remote.InboundHandler) {
					exist = true
					break
				}
			}
		case remote.OutboundHandler:
			for _, outboundHandler := range o.RemoteOpt.Outbounds {
				if outboundHandler == h.(remote.OutboundHandler) {
					exist = true
					break
				}
			}
		case remote.DuplexBoundHandler:
			for _, duplexboundHandler := range o.RemoteOpt.Inbounds {
				if duplexboundHandler == h.(remote.DuplexBoundHandler) {
					exist = true
					break
				}
			}
		}
		// prevent duplication
		if !exist {
			o.RemoteOpt.AppendBoundHandler(h)
		}
	}}
}


Review comment (suggestion):
In fact, DuplexBoundHandler is not necessary to be checked, because any DuplexBoundHandler also implements InboundHandler, you just need to check InboundHandler.

Code after:
		o.ErrHandle = f
	}}
}

// WithBoundHandler adds remote.BoundHandler for client.
func WithBoundHandler(h remote.BoundHandler) Option {
	return Option{F: func(o *client.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("AddBoundHandler(%T)", h))

		exist := false
		switch handler := h.(type) {
		case remote.InboundHandler:
			for _, inboundHandler := range o.RemoteOpt.Inbounds {
				if reflect.DeepEqual(inboundHandler, handler) {
					exist = true
					break
				}
			}
		case remote.OutboundHandler:
			for _, outboundHandler := range o.RemoteOpt.Outbounds {
				if reflect.DeepEqual(outboundHandler, handler) {
					exist = true
					break
				}
			}
		}
		// prevent duplication
		if !exist {
			o.RemoteOpt.AppendBoundHandler(h)
		}
	}}
}
Repository: cloudwego/kitex
File: pkg/generic/thrift/util.go (Go)

Code before:
		switch s {
		case "true":
			return true, nil
		case "false":
			return false, nil
		}
	case descriptor.I08:
		i, err := strconv.ParseInt(s, 10, 8)
		if err != nil {
			return nil, err
		}
		return int8(i), nil
	case descriptor.I16:
		i, err := strconv.ParseInt(s, 10, 16)
		if err != nil {
			return nil, err
		}
		return int16(i), nil
	case descriptor.I32:
		i, err := strconv.ParseInt(s, 10, 32)
		if err != nil {
			return nil, err
		}
		return int32(i), nil
	case descriptor.I64:
		if s == "" {
			s = "0"
		}
		i, err := strconv.ParseInt(s, 10, 64)
		if err != nil {
			return nil, err
		}
		return i, nil
	case descriptor.DOUBLE:
		return strconv.ParseFloat(s, 64)
	case descriptor.STRING:
		return s, nil
	case descriptor.LIST:
		strs := strings.Split(s, ",")
		if len(strs) == 0 {
			return nil, fmt.Errorf("expected list, got:%s", s)
		}
		res := make([]interface{}, len(strs))
		for i, str := range strs {
			val, err := buildinTypeFromString(str, t.Elem)
			if err != nil {
				return nil, err
			}
			res[i] = val
		}
		return res, nil

Review comment (suggestion):
Determining whether str is nil in this place will affect the behavior of all functions which use `buildinTypeFromString` function, it would be better to judge in `requestMappingValue` function.

Code after:
		case "true":
			return true, nil
		case "false":
			return false, nil
		}
	case descriptor.I08:
		i, err := strconv.ParseInt(s, 10, 8)
		if err != nil {
			return nil, err
		}
		return int8(i), nil
	case descriptor.I16:
		i, err := strconv.ParseInt(s, 10, 16)
		if err != nil {
			return nil, err
		}
		return int16(i), nil
	case descriptor.I32:
		i, err := strconv.ParseInt(s, 10, 32)
		if err != nil {
			return nil, err
		}
		return int32(i), nil
	case descriptor.I64:
		i, err := strconv.ParseInt(s, 10, 64)
		if err != nil {
			return nil, err
		}
		return i, nil
	case descriptor.DOUBLE:
		return strconv.ParseFloat(s, 64)
	case descriptor.STRING:
		return s, nil
	case descriptor.LIST:
		strs := strings.Split(s, ",")
		if len(strs) == 0 {
			return nil, fmt.Errorf("expected list, got:%s", s)
		}
		res := make([]interface{}, len(strs))
		for i, str := range strs {
			val, err := buildinTypeFromString(str, t.Elem)
			if err != nil {
				return nil, err
			}
			res[i] = val
		}
		return res, nil
	}
	return nil, fmt.Errorf("unsupported type:%s for parse buildin types from string", tt)
}
Repository: cloudwego/kitex
File: pkg/generic/thrift/util.go (Go)

Code before:
	idx := strings.LastIndex(t, ".")
	if idx == -1 {
		return "", t
	}
	return t[:idx], t[idx+1:]
}

func requestMappingValue(ctx context.Context, req *descriptor.HTTPRequest, field *descriptor.FieldDescriptor) (interface{}, error) {
	val, ok, err := field.HTTPMapping.Request(ctx, req, field)
	if err != nil {
		return nil, err
	}
	if !ok {
		return nil, nil
	}
	t := field.Type
	switch v := val.(type) {
	case nil:
		// json null
		return nil, nil
	case bool:
		return v, nil
	case json.Number:
		return buildinTypeFromString(string(v), t)
	case string:
		if v == "" && t.Type == descriptor.I64 {
			v = "0"
		}
		return buildinTypeFromString(v, t)
	case map[string]interface{}:
		return v, nil
	case []interface{}:
		return v, nil
	}
	return val, nil
}

func buildinTypeFromString(s string, t *descriptor.TypeDescriptor) (interface{}, error) {
	tt := t.Type
	switch tt {
	case descriptor.BOOL:
		switch s {
		case "true":
			return true, nil
		case "false":
			return false, nil
		}
	case descriptor.I08:
		i, err := strconv.ParseInt(s, 10, 8)
		if err != nil {
			return nil, err

Review comment (suggestion):
From a universal design perspective, we should return v if v is an empty string whatever t.Type is. In this way, If we need to add a new annotation, we won't meet a similar error.

Code after:
	idx := strings.LastIndex(t, ".")
	if idx == -1 {
		return "", t
	}
	return t[:idx], t[idx+1:]
}

func requestMappingValue(ctx context.Context, req *descriptor.HTTPRequest, field *descriptor.FieldDescriptor) (interface{}, error) {
	val, ok, err := field.HTTPMapping.Request(ctx, req, field)
	if err != nil {
		return nil, err
	}
	if !ok {
		return nil, nil
	}
	t := field.Type
	switch v := val.(type) {
	case json.Number:
		bt, err := buildinTypeFromString(string(v), t)
		if err != nil {
			return v, nil
		}
		return bt, nil
	case string:
		bt, err := buildinTypeFromString(v, t)
		if err != nil {
			return v, nil
		}
		return bt, err
	}
	return val, nil
}

func buildinTypeFromString(s string, t *descriptor.TypeDescriptor) (interface{}, error) {
	tt := t.Type
	switch tt {
	case descriptor.BOOL:
		switch s {
		case "true":
			return true, nil
		case "false":
			return false, nil
		}
	case descriptor.I08:
		i, err := strconv.ParseInt(s, 10, 8)
		if err != nil {
			return nil, err
		}
		return int8(i), nil
	case descriptor.I16:
		i, err := strconv.ParseInt(s, 10, 16)
Repository: cloudwego/kitex
File: pkg/remote/transmeta/metakey.go (Go)

Code before:
	HTTPContentType
	RawRingHashKey
	LBType
)

// key of header transport
const (
	HeaderTransRemoteAddr     = "rip"
	HeaderTransToCluster      = "tc"
	HeaderTransToIDC          = "ti"
	HeaderTransPerfTConnStart = "pcs"
	HeaderTransPerfTConnEnd   = "pce"
	HeaderTransPerfTSendStart = "pss"
	HeaderTransPerfTRecvStart = "prs"
	HeaderTransPerfTRecvEnd   = "pre"
	// the connection peer will shutdown later,so it send back the header to tell client to close the connection.
	HeaderConnectionReadyToReset = "crrst"
	HeaderProcessAtTime          = "K_ProcessAtTime"
)

// key of acl token
// You can set up acl token through metainfo.
// eg:
//
//	ctx = metainfo.WithValue(ctx, "gdpr-token", "your token")
//	ctx, err := tm.MetainfoClientHandler.WriteMeta(ctx, sendMsg)
const (
	// GDPRToken is used to set up gdpr token into InfoIDACLToken
	GDPRToken = metainfo.PrefixTransient + "gdpr-token"
)


Review comment (suggestion):
`ctx, err := tm.MetainfoClientHandler.WriteMeta(ctx, sendMsg)`
This line of code is confusing, users don't use MetainfoClientHandler directly, remove it.

Code after:
	HTTPContentType
	RawRingHashKey
	LBType
)

// key of header transport
const (
	HeaderTransRemoteAddr     = "rip"
	HeaderTransToCluster      = "tc"
	HeaderTransToIDC          = "ti"
	HeaderTransPerfTConnStart = "pcs"
	HeaderTransPerfTConnEnd   = "pce"
	HeaderTransPerfTSendStart = "pss"
	HeaderTransPerfTRecvStart = "prs"
	HeaderTransPerfTRecvEnd   = "pre"
	// the connection peer will shutdown later,so it send back the header to tell client to close the connection.
	HeaderConnectionReadyToReset = "crrst"
	HeaderProcessAtTime          = "K_ProcessAtTime"
)

// key of acl token
// You can set up acl token through metainfo.
// eg:
//
//	ctx = metainfo.WithValue(ctx, "gdpr-token", "your token")
const (
	// GDPRToken is used to set up gdpr token into InfoIDACLToken
	GDPRToken = metainfo.PrefixTransient + "gdpr-token"
)
Repository: cloudwego/kitex
File: pkg/loadbalance/weighted_round_robin.go (Go)

Code before:
	instances []discovery.Instance
	iterator  *round
}

func newRoundRobinPicker(instances []discovery.Instance) Picker {
	size := uint64(len(instances))
	return &RoundRobinPicker{
		size:      size,
		instances: instances,
		iterator:  newRandomRound(),
	}
}

// Next implements the Picker interface.
func (rp *RoundRobinPicker) Next(ctx context.Context, request interface{}) (ins discovery.Instance) {
	if rp.size == 0 {
		return nil
	}
	idx := rp.iterator.Next() % rp.size
	ins = rp.instances[idx]
	return ins
}

func gcdInt(a, b int) int {
	for b != 0 {
		r := a % b
		a = b
		b = r
	}
	return a
}


Review comment (suggestion):
```suggestion
		a, b = b, a%b
```
reduce variable declarations

Code after:
	instances []discovery.Instance
	iterator  *round
}

func newRoundRobinPicker(instances []discovery.Instance) Picker {
	size := uint64(len(instances))
	return &RoundRobinPicker{
		size:      size,
		instances: instances,
		iterator:  newRandomRound(),
	}
}

// Next implements the Picker interface.
func (rp *RoundRobinPicker) Next(ctx context.Context, request interface{}) (ins discovery.Instance) {
	if rp.size == 0 {
		return nil
	}
	idx := rp.iterator.Next() % rp.size
	ins = rp.instances[idx]
	return ins
}

func gcdInt(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
Repository: cloudwego/kitex
File: pkg/rpctimeout/item_rpc_timeout.go (Go)

Code before:
func (r *RPCTimeout) ConnectTimeout() time.Duration {
	return time.Duration(r.ConnTimeoutMS) * time.Millisecond
}

// ReadWriteTimeout implements rpcinfo.Timeouts
func (r *RPCTimeout) ReadWriteTimeout() time.Duration {
	return time.Duration(r.RPCTimeoutMS) * time.Millisecond
}

// NewContainer build Container for timeout provider.
func NewContainer() *Container {
	c := &Container{}
	rtc := &rpcTimeoutConfig{
		configs:      map[string]*RPCTimeout{},
		globalConfig: CopyDefaultRPCTimeout().(*RPCTimeout),
	}
	c.config.Store(rtc)
	return c
}

type rpcTimeoutConfig struct {
	configs      map[string]*RPCTimeout
	globalConfig *RPCTimeout
}

// Container the implementation of timeout provider..
type Container struct {
	config atomic.Value
}

// NotifyPolicyChange to receive policy when it changes
func (c *Container) NotifyPolicyChange(configs map[string]*RPCTimeout) {
	rtc := &rpcTimeoutConfig{
		configs:      configs,
		globalConfig: CopyDefaultRPCTimeout().(*RPCTimeout),
	}

	// if has wildcardMethod rpctimeout config, overwrite the default one.
	if config, ok := configs[wildcardMethod]; ok {
		rtc.globalConfig = config
	}
	c.config.Store(rtc)
}

// Timeouts return the rpc timeout config by the method name of rpc info.
func (c *Container) Timeouts(ri rpcinfo.RPCInfo) *RPCTimeout {
	rtc := c.config.Load().(*rpcTimeoutConfig)
	if config, ok := rtc.configs[ri.Invocation().MethodName()]; ok {
		return config
	}
	return rtc.globalConfig

Review comment (suggestion):
modify the description: Container is implementation of `rpcinfo.TimeoutProvider`.  
and please explain the purpose of this Container in comment 



Code after:
func (r *RPCTimeout) ConnectTimeout() time.Duration {
	return time.Duration(r.ConnTimeoutMS) * time.Millisecond
}

// ReadWriteTimeout implements rpcinfo.Timeouts
func (r *RPCTimeout) ReadWriteTimeout() time.Duration {
	return time.Duration(r.RPCTimeoutMS) * time.Millisecond
}

// NewContainer build Container for timeout provider.
func NewContainer() *Container {
	c := &Container{}
	rtc := &rpcTimeoutConfig{
		configs:      map[string]*RPCTimeout{},
		globalConfig: CopyDefaultRPCTimeout().(*RPCTimeout),
	}
	c.config.Store(rtc)
	return c
}

type rpcTimeoutConfig struct {
	configs      map[string]*RPCTimeout
	globalConfig *RPCTimeout
}

// Container is the implementation of rpcinfo.TimeoutProvider.
// Provide the ability to dynamically configure the rpctimeout
// config on the method hierarchy.
type Container struct {
	config atomic.Value
}

// NotifyPolicyChange to receive policy when it changes
func (c *Container) NotifyPolicyChange(configs map[string]*RPCTimeout) {
	rtc := &rpcTimeoutConfig{
		configs:      map[string]*RPCTimeout{},
		globalConfig: CopyDefaultRPCTimeout().(*RPCTimeout),
	}

	for method, cfg := range configs {
		// The configs may be modified by the container invoker,
		// copy them to avoid data race.
		rt := cfg.DeepCopy().(*RPCTimeout)

		// if has wildcardMethod rpctimeout config, overwrite the default one.
		if method == wildcardMethod {
			rtc.globalConfig = rt
		}
		rtc.configs[method] = rt
	}