From 69935c1ba34db9cd04b85930f5e0605f6cdb5c9a Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Wed, 11 Aug 2021 18:08:01 +0800 Subject: [PATCH] refactor goctl, fix golint issues (#903) --- core/contextx/unmarshaler_test.go | 1 - core/mapping/unmarshaler.go | 1 - tools/goctl/model/sql/builderx/builder.go | 10 +++++----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/core/contextx/unmarshaler_test.go b/core/contextx/unmarshaler_test.go index 42f9db73..5e7abf05 100644 --- a/core/contextx/unmarshaler_test.go +++ b/core/contextx/unmarshaler_test.go @@ -8,7 +8,6 @@ import ( ) func TestUnmarshalContext(t *testing.T) { - type Person struct { Name string `ctx:"name"` Age int `ctx:"age"` diff --git a/core/mapping/unmarshaler.go b/core/mapping/unmarshaler.go index abf2df99..63bea68b 100644 --- a/core/mapping/unmarshaler.go +++ b/core/mapping/unmarshaler.go @@ -524,7 +524,6 @@ func (u *Unmarshaler) fillSliceValue(slice reflect.Value, index int, baseKind re return errTypeMismatch } - ithVal.Set(reflect.ValueOf(value)) return nil } diff --git a/tools/goctl/model/sql/builderx/builder.go b/tools/goctl/model/sql/builderx/builder.go index 0106f021..f579c0e3 100644 --- a/tools/goctl/model/sql/builderx/builder.go +++ b/tools/goctl/model/sql/builderx/builder.go @@ -10,17 +10,17 @@ import ( const dbTag = "db" -// NewEq wraps builder.Eq +// NewEq wraps builder.Eq. func NewEq(in interface{}) builder.Eq { return builder.Eq(ToMap(in)) } -// NewGt wraps builder.Gt +// NewGt wraps builder.Gt. func NewGt(in interface{}) builder.Gt { return builder.Gt(ToMap(in)) } -// ToMap converts interface into map +// ToMap converts interface into map. func ToMap(in interface{}) map[string]interface{} { out := make(map[string]interface{}) v := reflect.ValueOf(in) @@ -81,7 +81,7 @@ func FieldNames(in interface{}) []string { return out } -// RawFieldNames converts golang struct field into slice string +// RawFieldNames converts golang struct field into slice string. func RawFieldNames(in interface{}, postgresSql ...bool) []string { out := make([]string, 0) v := reflect.ValueOf(in) @@ -121,7 +121,7 @@ func RawFieldNames(in interface{}, postgresSql ...bool) []string { return out } -//PostgreSqlJoin concatenate the given elements into a string +// PostgreSqlJoin concatenates the given elements into a string. func PostgreSqlJoin(elems []string) string { b := new(strings.Builder) for index, e := range elems {