Skip to content

Commit

Permalink
Code cleanup, update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
sonh committed Jun 9, 2021
1 parent bfdeb5e commit 8e03ada
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Package sonh/qs encodes structs into url.Values.

## Installation
```shell
```bash
go get github.com/sonh/qs
```

Expand Down Expand Up @@ -166,9 +166,9 @@ fmt.Println(values.Encode()) //(unescaped) output: "user[from]=1601623397728&use
```

### Custom Type
Implement `EncodeParam` to encode itself into query param.

Implement `IsZero` to check whether an object is zero to determine whether it should be omitted when encoding.
Implement funcs:
* `EncodeParam` to encode itself into query param.
* `IsZero` to check whether an object is zero to determine whether it should be omitted when encoding.
```go
type NullableName struct {
First string
Expand Down
5 changes: 0 additions & 5 deletions encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,6 @@ func (e *encoder) structCaching(fields *cachedFields, stVal reflect.Value, scope

fieldTyp := getType(fieldVal)

/*if formatter := e.e.formatters[fieldTyp]; formatter != nil {
*fields = append(*fields, newCustomField(fieldTyp, e.tags[0], e.tags[1:], formatter))
continue
}*/

if fieldTyp == timeType {
*fields = append(*fields, newTimeField(e.tags[0], e.tags[1:]))
continue
Expand Down
2 changes: 1 addition & 1 deletion example/basic/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func main() {
values, err := encoder.Values(query)
if err != nil {
// Handle error
fmt.Println("failed")
fmt.Println(err)
return
}
fmt.Println(values.Encode())
Expand Down

0 comments on commit 8e03ada

Please sign in to comment.