Skip to content

Commit 4d51320

Browse files
committed
documentation is done and making v0.1 release
1 parent bc34938 commit 4d51320

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Robust & Easy to use model mapper and model utility methods for Go. Typical meth
55
go-model tested with Go `v1.2` and above.
66

77
## Features
8-
go-model provides handy methods to process struct with below highlighted features. It's born from typical need while developing Go application or utility. I hope it's helpful!
8+
go-model provides handy methods (`Copy`, `Map`, `IsZero`, etc.) to process struct with below highlighted features. It's born from typical need while developing Go application or utility. I hope it's helpful!
99
* Embedded/Anonymous struct
1010
* Multi-level nested struct/map/slice
1111
* Pointer and non-pointer within struct/map/slice
@@ -47,10 +47,9 @@ import (
4747
* RemoveNoTraverseType - [usage](#addnotraversetype--removenotraversetype-methods), [godoc](https://godoc.org/github.com/jeevatkm/go-model#RemoveNoTraverseType)
4848

4949
#### Copy Method
50-
How do I copy my struct object into another? Not to worry go-model does deep copy.
50+
How do I copy my struct object into another? Not to worry, go-model does deep copy.
5151
```go
52-
// let's say you have just decoded/unmarshalled your request body into object
53-
// may be intermediate struct 'TempProduct' for parsing user input
52+
// let's say you have just decoded/unmarshalled your request body to struct object.
5453
tempProduct, _ := myapp.ParseJSON(request.Body)
5554

5655
product := Product{}
@@ -66,7 +65,7 @@ fmt.Printf("\nDestination: %#v\n", product)
6665
```
6766

6867
#### Map Method
69-
I want to convert my struct into Map (`map[string]interface{}`). Not to worry go-model does deep convert.
68+
I want to convert my struct into Map (`map[string]interface{}`). Not to worry, go-model does deep convert.
7069
```go
7170
// tag your SearchResult fields with appropriate options like
7271
// -, name, omitempty, notraverse to get desired result.
@@ -79,9 +78,9 @@ fmt.Printf("\nSearch Result Map: %#v\n", srchResMap)
7978
```
8079

8180
#### IsZero Method
82-
I want to check my struct object is empty or not. Not to worry go-model does deep zero check.
81+
I want to check my struct object is empty or not. Not to worry, go-model does deep zero check.
8382
```go
84-
// let's you have just decoded/unmarshalled your request body into object
83+
// let's say you have just decoded/unmarshalled your request body to struct object.
8584
productInfo, _ := myapp.ParseJSON(request.Body)
8685

8786
// wanna check productInfo is empty or not
@@ -93,11 +92,11 @@ fmt.Println("Hey, I have zero values:", isEmpty)
9392
```
9493

9594
#### AddNoTraverseType & RemoveNoTraverseType Methods
96-
There are scenarios, you want object values but not to traverse/look inside the struct object. Use `notraverse` option in the model tag for those fieds or Add it `NoTraverseTypeList`. Customize it as per your need.
95+
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.
9796

9897
Default `NoTraverseTypeList` has these types `time.Time{}`, `&time.Time{}`, `os.File{}`, `&os.File{}`, `http.Request{}`, `&http.Request{}`, `http.Response{}`, `&http.Response{}`.
9998
```go
100-
// If you have added your type into list then you no need to mention `notraverse` option for those types.
99+
// If you have added your type into list then you need not mention `notraverse` option for those types.
101100

102101
// Adding type into NoTraverseTypeList
103102
model.AddNoTraverseType(time.Location{}, &time.Location{})
@@ -109,10 +108,10 @@ model.RemoveNoTraverseType(time.Location{}, &time.Location{})
109108
## Versioning
110109
go-model releases versions according to [Semantic Versioning](http://semver.org)
111110

112-
`gopkg.in/jeevatkm/go-model.vX` points to appropriate tag versions; `X` denotes version number and it's a stable release. It's recommended to use version, for eg. `gopkg.in/jeevatkm/go-model.v0`. Development takes place at the master branch. Althought the code in master should always compile and test successfully, it might break API's. We aim to maintain backwards compatibility, but API's and behaviour might be changed to fix a bug.
111+
`gopkg.in/jeevatkm/go-model.vX` points to appropriate tag versions; `X` denotes version number and it's a stable release. It's recommended to use version, for eg. `gopkg.in/jeevatkm/go-model.v0`. Development takes place at the master branch. Although the code in master should always compile and test successfully, it might break API's. We aim to maintain backwards compatibility, but API's and behaviour might be changed to fix a bug.
113112

114113
## Contributing
115-
Welcome! If you find any improvement or issue you want to fix. Feel free to send a pull request, I like pull requests that include tests case for fix/enhancement. Did my best to bring pretty good code coverage and feel free to write tests.
114+
Welcome! If you find any improvement or issue you want to fix, feel free to send a pull request. I like pull requests that include test cases for fix/enhancement. I have done my best to bring pretty good code coverage. Feel free to write tests.
116115

117116
BTW, I'd like to know what you think about go-model. Kindly open an issue or send me an email; it'd mean a lot to me.
118117

model.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ func IsZero(s interface{}) bool {
155155
//
156156
// Example:
157157
//
158-
// src := SampleStruct{ /* source struct field values goes here */ }
159-
// dst := SampleStruct{}
158+
// src := SampleStruct { /* source struct field values go here */ }
159+
// dst := SampleStruct {}
160160
//
161161
// errs := model.Copy(&dst, src)
162162
// if errs != nil {
@@ -166,7 +166,7 @@ func IsZero(s interface{}) bool {
166166
// Note:
167167
// [1] Copy process continues regardless of the case it qualifies or not. The non-qualified field(s)
168168
// gets added to '[]error' that you will get at the end.
169-
// [2] Two dimensional slice type is not yet supported.
169+
// [2] Two dimensional slice type is not supported yet.
170170
//
171171
// A "model" tag with the value of "-" is ignored by library for processing.
172172
// Example:
@@ -220,23 +220,23 @@ func Copy(dst, src interface{}) []error {
220220
return nil
221221
}
222222

223-
// Map method converts all the exported field values from given struct into `map[string]interface{}`.
224-
// Where the keys of the map are the field names and the values of the map is associated
223+
// Map method converts all the exported field values from the given struct into `map[string]interface{}`.
224+
// In which the keys of the map are the field names and the values of the map are the associated
225225
// values of the field.
226226
//
227227
// Example:
228228
//
229-
// src := SampleStruct{ /* source struct field values goes here */ }
229+
// src := SampleStruct { /* source struct field values go here */ }
230230
//
231231
// err := model.Map(src)
232232
// if err != nil {
233233
// fmt.Println("Error:", err)
234234
// }
235235
//
236236
// Note:
237-
// [1] Two dimensional slice type is not yet supported.
237+
// [1] Two dimensional slice type is not supported yet.
238238
//
239-
// The default 'Key Name' string is the struct field name. However, can be
239+
// The default 'Key Name' string is the struct field name. However, it can be
240240
// changed in the struct field's tag value via "model" tag.
241241
// Example:
242242
//
@@ -251,7 +251,7 @@ func Copy(dst, src interface{}) []error {
251251
// BookCode string `model:"-"`
252252
//
253253
// A "model" tag value with the option of "omitempty"; library will not include those values
254-
// while converting into map[string]interface{}. If it's empty/zero value.
254+
// while converting to map[string]interface{}. If it's empty/zero value.
255255
// Example:
256256
//
257257
// // Field is not included in result map if it's empty/zero value
@@ -260,7 +260,7 @@ func Copy(dst, src interface{}) []error {
260260
//
261261
// A "model" tag value with the option of "notraverse"; library will not traverse
262262
// inside the struct object. However, the field value will be evaluated whether
263-
// it's zero value or not then accordingly added to the result map.
263+
// it's zero value or not, and then added to the result map accordingly.
264264
// Example:
265265
//
266266
// // Field is not traversed but value is evaluated/processed

0 commit comments

Comments
 (0)