Skip to content

Commit

Permalink
feat(debug): control log
Browse files Browse the repository at this point in the history
  • Loading branch information
nukc committed Apr 7, 2023
1 parent 730aba5 commit 34fd303
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tagsugar.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

var (
Http = ""
Debug = false
hostMap = make(map[string]string, 0)
)

Expand Down Expand Up @@ -44,7 +45,9 @@ func resolveValue(v reflect.Value, k reflect.Kind) {
v, k = getEkByValue(v)
resolveValue(v, k)
default:
log.Print("Ignore kind: " + k.String())
if Debug {
log.Print("Ignore kind: " + k.String())
}
}
}

Expand Down Expand Up @@ -90,7 +93,7 @@ func resolveField(value reflect.Value) {

sf := p.Field(i)
options := parseTag(sf.Tag.Get("ts"))
if err := changeField(value, field, options); err != nil {
if err := changeField(value, field, options); err != nil && Debug {
log.Print(err)
}

Expand Down
1 change: 1 addition & 0 deletions tagsugar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

func TestModel(t *testing.T) {
Http = "https://cdn.github.com/"
Debug = true

json := "{\"id\": 1, \"post\": 2}"
array := "[{\"id\": 1, \"post\": 3},{\"id\": 2, \"post\": 66}]"
Expand Down

0 comments on commit 34fd303

Please sign in to comment.