Skip to content

Commit

Permalink
fix: vto type error
Browse files Browse the repository at this point in the history
  • Loading branch information
songzhibin97 committed May 3, 2023
1 parent dd69e85 commit fa92845
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,9 @@ func main() {
## container
Containerized components
> Pool, but you can customize the creation function and replace the initialization function.
> pool pooling object, through the configuration can set the maximum number of connections and the number of waiting connections, synchronous asynchronous acquisition of connections, and connection life cycle management, you can customize the creation function, and replace the initialization function
> codel implement codel algorithm, can be used to limit the flow, and fuse
### group
Expand Down
4 changes: 3 additions & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,9 @@ func main() {

## container

容器化组件
> group 适用于生命周期较长对象的懒加载,类似于 sync.Pool,但是可以自定义创建函数,以及更换初始化函数
> pool 池化对象,通过配置可以设置最大连接数以及等待连接数,同步异步获取连接,以及连接的生命周期管理,可以自定义创建函数,以及更换初始化函数
> codel 实现codel算法,可以用于限流,以及熔断
### group

Expand Down
2 changes: 1 addition & 1 deletion container/pool/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (l *List) Put(ctx context.Context, s IShutdown, forceClose bool) error {
return s.Shutdown()
}

// IShutdown 关闭
// Shutdown 关闭
func (l *List) Shutdown() error {
l.mu.Lock()
if atomic.SwapUint32(&l.closed, 1) == 1 {
Expand Down
16 changes: 12 additions & 4 deletions tools/vto/votodo.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func VoToDo(dst interface{}, src interface{}) error {
continue
}

if d.Type() != s.Type() && d.Kind() == reflect.Struct {
if d.Kind() != s.Kind() && d.Kind() == reflect.Struct {
err := VoToDo(d.Addr().Interface(), s.Addr().Interface())
if err != nil {
return err
Expand All @@ -67,7 +67,11 @@ func VoToDo(dst interface{}, src interface{}) error {
}

if !s.IsZero() {
d.Set(s)
if d.Type() == s.Type() {
d.Set(s)
} else {
d.Set(reflect.ValueOf(s.Interface()).Convert(d.Type()))
}
}

// 如果源位置的内容为空,并且默认值不为0
Expand Down Expand Up @@ -131,7 +135,7 @@ func VoToDoPlus(dst interface{}, src interface{}, model ModelParameters) error {
continue
}

if d.Type() != s.Type() && d.Kind() == reflect.Struct {
if d.Kind() != s.Kind() && d.Kind() == reflect.Struct {
err := VoToDoPlus(d.Addr().Interface(), s.Addr().Interface(), model)
if err != nil {
return err
Expand All @@ -140,7 +144,11 @@ func VoToDoPlus(dst interface{}, src interface{}, model ModelParameters) error {
}

if !s.IsZero() {
d.Set(s)
if d.Type() == s.Type() {
d.Set(s)
} else {
d.Set(reflect.ValueOf(s.Interface()).Convert(d.Type()))
}
}
}
}
Expand Down

0 comments on commit fa92845

Please sign in to comment.