Skip to content

Commit

Permalink
Merge pull request #2 from sobhanatar/fix_data_func
Browse files Browse the repository at this point in the history
fix data function to recieve interface
  • Loading branch information
mahyar78 authored Nov 12, 2022
2 parents 7f544a3 + 3e37ad9 commit 9a4cfff
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions success.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
type resData struct {
total int
perPage int
result []map[string]interface{}
result interface{}
}

type response struct {
Expand Down Expand Up @@ -36,15 +36,13 @@ func (r *response) Version(v string) *response {
return r
}

func (r *response) Data(d []map[string]interface{}) *response {
for _, data := range d {
r.data.result = append(r.data.result, data)
}
func (r *response) Data(d interface{}) *response {
r.data.result = d
return r
}

func (r *response) SingleData(d map[string]interface{}) *response {
r.data.result = append(r.data.result, d)
func (r *response) SingleData(d interface{}) *response {
r.data.result = d
return r
}

Expand All @@ -69,9 +67,6 @@ func (r *response) HttpCode(hc int) *response {
}

func (r *response) Generate() map[string]interface{} {
if len(r.data.result) == 0 {
r.data.result = []map[string]interface{}{}
}
resp := map[string]interface{}{
"message": r.message,
"error": r.error,
Expand Down

0 comments on commit 9a4cfff

Please sign in to comment.