Skip to content

Commit

Permalink
v0.5 release readme update
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
jeevatkm committed Jan 2, 2017
1 parent b63a4a2 commit 723d875
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

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

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

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

#### Get Method
I want to get value by field name on my `struct`. Yes, it is easy to get it.
```go
src := SampleStruct {
BookCount: 100,
BookCode: "GHT67HH00",
}

value, _ := model.Get(src, "BookCode")
fmt.Println("Value:", value)

// Output:
Value: GHT67HH00
```

#### Set Method
I want to set value by field name on my `struct`. Yes, it is easy to get it.
```go
src := SampleStruct {
BookCount: 100,
BookCode: "GHT67HH00",
}

err := model.Set(&src, "BookCount", 200)
fmt.Println("Error:", err)
```

#### AddNoTraverseType & RemoveNoTraverseType Methods
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.

Expand All @@ -214,7 +244,7 @@ model.AddNoTraverseType(time.Location{}, &time.Location{})
model.RemoveNoTraverseType(time.Location{}, &time.Location{})
```

#### AddConversion & RemoveConversion Method
#### AddConversion & RemoveConversion Methods

This example registers a custom conversion from the `int` to the `string` type.
```go
Expand Down

0 comments on commit 723d875

Please sign in to comment.