diff --git a/datasource/datasource.go b/datasource/datasource.go index 71331fc..42b4c3a 100644 --- a/datasource/datasource.go +++ b/datasource/datasource.go @@ -8,5 +8,5 @@ type DataSource interface { // - Get("port") // - Get("redis.port") // - Get("address.city.houses.0.id") - Get(key string) (any, error) + Get(key string) any } diff --git a/datasource/map.go b/datasource/map.go index 96dbf20..0ca4279 100644 --- a/datasource/map.go +++ b/datasource/map.go @@ -18,6 +18,6 @@ func NewMapDataSource(data map[string]any) DataSource { // - Get("port") // - Get("redis.port") // - Get("address.city.houses.0.id") -func (m *mapDataSource) Get(key string) (any, error) { - return object.Get(m.data, key), nil +func (m *mapDataSource) Get(key string) any { + return object.Get(m.data, key) } diff --git a/go.mod b/go.mod index b87f621..fb9144a 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,6 @@ module github.com/go-zoox/tag go 1.18 -require github.com/go-zoox/core-utils v1.3.4 +require github.com/go-zoox/core-utils v1.3.5 require github.com/spf13/cast v1.5.0 // indirect diff --git a/go.sum b/go.sum index 90b7abe..0e415ef 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= -github.com/go-zoox/core-utils v1.3.4 h1:qfapS7+tNWIz0TDyAICfdeIL2QLS1iJ8+mZWq4NInbE= -github.com/go-zoox/core-utils v1.3.4/go.mod h1:raOOwr2l2sJQyjR0Dg33sg0ry4U1/L2eNTuLFRpUXWs= +github.com/go-zoox/core-utils v1.3.5 h1:uxnPjUdo20ZCYCJp+1deuoqdMByTTJxQFrMp8e5ty+E= +github.com/go-zoox/core-utils v1.3.5/go.mod h1:raOOwr2l2sJQyjR0Dg33sg0ry4U1/L2eNTuLFRpUXWs= github.com/go-zoox/testify v1.0.2 h1:G5sQ3xm0uwCuytnMhgnqZ5BItCt2DN3n2wLBqlIJEWA= github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= diff --git a/tag.go b/tag.go index 243f688..ffc8cab 100644 --- a/tag.go +++ b/tag.go @@ -43,12 +43,7 @@ func (t *Tag) decodeR(ptr interface{}, keyPathParent string) error { attribute := attribute.New(rtt.Name, rtt.Type.String(), keyPathParent, rtt.Tag.Get(tagName)) // fmt.Println("keyPathParent:", keyPathParent, rtt.Name, attribute.GetKey()) - v, err := dataSource.Get(attribute.GetKey()) - if err != nil { - return err - } - - if err := attribute.SetValue(v); err != nil { + if err := attribute.SetValue(dataSource.Get(attribute.GetKey())); err != nil { return err } diff --git a/tag_test.go b/tag_test.go index 7eed188..fedad17 100644 --- a/tag_test.go +++ b/tag_test.go @@ -78,8 +78,8 @@ var TestStructDataSourceData = map[string]interface{}{ "type_transform": "666", } -func (t *TestStructDataSource) Get(key string) (interface{}, error) { - return object.Get(TestStructDataSourceData, key), nil +func (t *TestStructDataSource) Get(key string) any { + return object.Get(TestStructDataSourceData, key) } func TestTag(t *testing.T) { diff --git a/version.go b/version.go index d0df8ca..b1b4612 100644 --- a/version.go +++ b/version.go @@ -1,4 +1,4 @@ package tag // Version is the version of tag. -var Version = "1.2.5" +var Version = "1.2.6"