avoid having package name in local struct

This commit is contained in:
Celogeek 2024-03-03 12:28:00 +01:00
parent d1dc0e72f6
commit f8b76a3725
Signed by: celogeek
SSH Key Fingerprint: SHA256:njNJLzoLQdbV9PC6ehcruRb0QnEgxABoCYZ+0+aUIYc

View File

@ -14,7 +14,7 @@ import (
"github.com/celogeek/piwigo-cli/internal/debug" "github.com/celogeek/piwigo-cli/internal/debug"
) )
type PiwigoResult struct { type PostResult struct {
Stat string `json:"stat"` Stat string `json:"stat"`
Err int `json:"err"` Err int `json:"err"`
ErrMessage string `json:"message"` ErrMessage string `json:"message"`
@ -46,7 +46,7 @@ func (p *Piwigo) Post(method string, form *url.Values, resp interface{}) error {
encodedForm = form.Encode() encodedForm = form.Encode()
} }
Result := PiwigoResult{ result := PostResult{
Result: resp, Result: resp,
} }
@ -81,7 +81,7 @@ func (p *Piwigo) Post(method string, form *url.Values, resp interface{}) error {
continue continue
} }
err = json.Unmarshal(raw.Bytes(), &Result) err = json.Unmarshal(raw.Bytes(), &result)
if err != nil { if err != nil {
_ = r.Body.Close() _ = r.Body.Close()
continue continue
@ -112,8 +112,8 @@ func (p *Piwigo) Post(method string, form *url.Values, resp interface{}) error {
fmt.Println(debug.Dump(RawResult)) fmt.Println(debug.Dump(RawResult))
} }
if Result.Stat != "ok" { if result.Stat != "ok" {
return fmt.Errorf("[Error %d] %s", Result.Err, Result.ErrMessage) return fmt.Errorf("[Error %d] %s", result.Err, result.ErrMessage)
} }
return nil return nil