Skip to content

Commit 723d875

Browse files
committed
v0.5 release readme update
[ci skip]
1 parent b63a4a2 commit 723d875

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Robust & Easy to use model mapper and utility methods for Go `struct`. Typical methods increase productivity and make Go development more fun :smile:
44

5-
***v0.4 released and tagged on May 19, 2016***
5+
***v0.5 [released](https://github.com/jeevatkm/go-model/releases/latest) and tagged on Jan 02, 2017***
66

77
go-model tested with Go `v1.2` and above.
88

@@ -17,6 +17,7 @@ go-model library provides [handy methods](#supported-methods) to process `struct
1717
* Get struct field `reflect.Kind` by field name
1818
* Get all the struct field tags (`reflect.StructTag`) or selectively by field name
1919
* Get all `reflect.StructField` for given struct instance
20+
* Get or Set by individual field name on struct
2021
* Add global no traverse type to the list or use `notraverse` option in the struct field
2122
* Options to name map key, omit empty fields, and instruct not to traverse with struct/map/slice
2223
* Conversions between mixed non-pointer types
@@ -56,6 +57,8 @@ import (
5657
* Kind - [usage](#kind-method), [godoc](https://godoc.org/github.com/jeevatkm/go-model#Kind)
5758
* Tag - [usage](#tag-method), [godoc](https://godoc.org/github.com/jeevatkm/go-model#Tag)
5859
* Tags - [usage](#tags-method), [godoc](https://godoc.org/github.com/jeevatkm/go-model#Tags)
60+
* Get - [usage](#get-method), [godoc](https://godoc.org/github.com/jeevatkm/go-model#Get)
61+
* Set - [usage](#set-method), [godoc](https://godoc.org/github.com/jeevatkm/go-model#Set)
5962
* AddNoTraverseType - [usage](#addnotraversetype--removenotraversetype-methods), [godoc](https://godoc.org/github.com/jeevatkm/go-model#AddNoTraverseType)
6063
* RemoveNoTraverseType - [usage](#addnotraversetype--removenotraversetype-methods), [godoc](https://godoc.org/github.com/jeevatkm/go-model#RemoveNoTraverseType)
6164
* AddConversion - [usage](#addconversion--removeconversion-methods), [godoc](https://godoc.org/github.com/jeevatkm/go-model#AddConversion)
@@ -200,6 +203,33 @@ tags, _ := model.Tags(src)
200203
fmt.Println("Tags:", tags)
201204
```
202205

206+
#### Get Method
207+
I want to get value by field name on my `struct`. Yes, it is easy to get it.
208+
```go
209+
src := SampleStruct {
210+
BookCount: 100,
211+
BookCode: "GHT67HH00",
212+
}
213+
214+
value, _ := model.Get(src, "BookCode")
215+
fmt.Println("Value:", value)
216+
217+
// Output:
218+
Value: GHT67HH00
219+
```
220+
221+
#### Set Method
222+
I want to set value by field name on my `struct`. Yes, it is easy to get it.
223+
```go
224+
src := SampleStruct {
225+
BookCount: 100,
226+
BookCode: "GHT67HH00",
227+
}
228+
229+
err := model.Set(&src, "BookCount", 200)
230+
fmt.Println("Error:", err)
231+
```
232+
203233
#### AddNoTraverseType & RemoveNoTraverseType Methods
204234
There are scenarios, where you want the object values but not to traverse/look inside the struct object. Use `notraverse` option in the model tag for those fields or Add it `NoTraverseTypeList`. Customize it as per your need.
205235

@@ -214,7 +244,7 @@ model.AddNoTraverseType(time.Location{}, &time.Location{})
214244
model.RemoveNoTraverseType(time.Location{}, &time.Location{})
215245
```
216246

217-
#### AddConversion & RemoveConversion Method
247+
#### AddConversion & RemoveConversion Methods
218248

219249
This example registers a custom conversion from the `int` to the `string` type.
220250
```go

0 commit comments

Comments
 (0)