fix unmarshal argument pointer
This commit is contained in:
parent
bfcb423cdf
commit
25050d2f0e
5 changed files with 44 additions and 37 deletions
|
@ -1,5 +1,7 @@
|
||||||
package v1
|
package v1
|
||||||
|
|
||||||
|
// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -7,209 +9,207 @@ import (
|
||||||
client_protocol "gitlab.com/signald/signald-go/signald/client-protocol"
|
client_protocol "gitlab.com/signald/signald-go/signald/client-protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo
|
|
||||||
|
|
||||||
func mkerr(response client_protocol.BasicResponse) error {
|
func mkerr(response client_protocol.BasicResponse) error {
|
||||||
switch response.ErrorType {
|
switch response.ErrorType {
|
||||||
case "AccountAlreadyVerifiedError":
|
case "AccountAlreadyVerifiedError":
|
||||||
result := AccountAlreadyVerifiedError{}
|
result := AccountAlreadyVerifiedError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "AccountHasNoKeysError":
|
case "AccountHasNoKeysError":
|
||||||
result := AccountHasNoKeysError{}
|
result := AccountHasNoKeysError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "AccountLockedError":
|
case "AccountLockedError":
|
||||||
result := AccountLockedError{}
|
result := AccountLockedError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "CaptchaRequiredError":
|
case "CaptchaRequiredError":
|
||||||
result := CaptchaRequiredError{}
|
result := CaptchaRequiredError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "FingerprintVersionMismatchError":
|
case "FingerprintVersionMismatchError":
|
||||||
result := FingerprintVersionMismatchError{}
|
result := FingerprintVersionMismatchError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "GroupLinkNotActiveError":
|
case "GroupLinkNotActiveError":
|
||||||
result := GroupLinkNotActiveError{}
|
result := GroupLinkNotActiveError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "GroupNotActiveError":
|
case "GroupNotActiveError":
|
||||||
result := GroupNotActiveError{}
|
result := GroupNotActiveError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "GroupVerificationError":
|
case "GroupVerificationError":
|
||||||
result := GroupVerificationError{}
|
result := GroupVerificationError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "InternalError":
|
case "InternalError":
|
||||||
result := InternalError{}
|
result := InternalError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "InvalidAttachmentError":
|
case "InvalidAttachmentError":
|
||||||
result := InvalidAttachmentError{}
|
result := InvalidAttachmentError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "InvalidBase64Error":
|
case "InvalidBase64Error":
|
||||||
result := InvalidBase64Error{}
|
result := InvalidBase64Error{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "InvalidFingerprintError":
|
case "InvalidFingerprintError":
|
||||||
result := InvalidFingerprintError{}
|
result := InvalidFingerprintError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "InvalidGroupError":
|
case "InvalidGroupError":
|
||||||
result := InvalidGroupError{}
|
result := InvalidGroupError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "InvalidGroupStateError":
|
case "InvalidGroupStateError":
|
||||||
result := InvalidGroupStateError{}
|
result := InvalidGroupStateError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "InvalidInviteURIError":
|
case "InvalidInviteURIError":
|
||||||
result := InvalidInviteURIError{}
|
result := InvalidInviteURIError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "InvalidProxyError":
|
case "InvalidProxyError":
|
||||||
result := InvalidProxyError{}
|
result := InvalidProxyError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "InvalidRecipientError":
|
case "InvalidRecipientError":
|
||||||
result := InvalidRecipientError{}
|
result := InvalidRecipientError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "InvalidRequestError":
|
case "InvalidRequestError":
|
||||||
result := InvalidRequestError{}
|
result := InvalidRequestError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "NoKnownUUIDError":
|
case "NoKnownUUIDError":
|
||||||
result := NoKnownUUIDError{}
|
result := NoKnownUUIDError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "NoSendPermissionError":
|
case "NoSendPermissionError":
|
||||||
result := NoSendPermissionError{}
|
result := NoSendPermissionError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "NoSuchAccountError":
|
case "NoSuchAccountError":
|
||||||
result := NoSuchAccountError{}
|
result := NoSuchAccountError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "NoSuchSessionError":
|
case "NoSuchSessionError":
|
||||||
result := NoSuchSessionError{}
|
result := NoSuchSessionError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "OwnProfileKeyDoesNotExistError":
|
case "OwnProfileKeyDoesNotExistError":
|
||||||
result := OwnProfileKeyDoesNotExistError{}
|
result := OwnProfileKeyDoesNotExistError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "ProfileUnavailableError":
|
case "ProfileUnavailableError":
|
||||||
result := ProfileUnavailableError{}
|
result := ProfileUnavailableError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "ServerNotFoundError":
|
case "ServerNotFoundError":
|
||||||
result := ServerNotFoundError{}
|
result := ServerNotFoundError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "UnknownGroupError":
|
case "UnknownGroupError":
|
||||||
result := UnknownGroupError{}
|
result := UnknownGroupError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "UnknownIdentityKeyError":
|
case "UnknownIdentityKeyError":
|
||||||
result := UnknownIdentityKeyError{}
|
result := UnknownIdentityKeyError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "UntrustedIdentityError":
|
case "UntrustedIdentityError":
|
||||||
result := UntrustedIdentityError{}
|
result := UntrustedIdentityError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
case "UserAlreadyExistsError":
|
case "UserAlreadyExistsError":
|
||||||
result := UserAlreadyExistsError{}
|
result := UserAlreadyExistsError{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package {{.Version}}
|
package {{.Version}}
|
||||||
|
|
||||||
|
// {{ .Banner }}
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -7,13 +9,11 @@ import (
|
||||||
client_protocol "gitlab.com/signald/signald-go/signald/client-protocol"
|
client_protocol "gitlab.com/signald/signald-go/signald/client-protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo
|
|
||||||
|
|
||||||
func mkerr(response client_protocol.BasicResponse) error {
|
func mkerr(response client_protocol.BasicResponse) error {
|
||||||
switch response.ErrorType { {{ range $structName, $type := .Types }}
|
switch response.ErrorType { {{ range $structName, $type := .Types }}
|
||||||
case "{{ $structName }}":
|
case "{{ $structName }}":
|
||||||
result := {{ $structName }}{}
|
result := {{ $structName }}{}
|
||||||
err := json.Unmarshal(response.Error, result)
|
err := json.Unmarshal(response.Error, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,12 +41,14 @@ type StructsTemplateInput struct {
|
||||||
Types map[string]*Type
|
Types map[string]*Type
|
||||||
Version string
|
Version string
|
||||||
ImportVersions []string
|
ImportVersions []string
|
||||||
|
Banner string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ActionsTemplateInput struct {
|
type ActionsTemplateInput struct {
|
||||||
Actions map[string]*Action
|
Actions map[string]*Action
|
||||||
Version string
|
Version string
|
||||||
Responses bool
|
Responses bool
|
||||||
|
Banner string
|
||||||
}
|
}
|
||||||
|
|
||||||
var typeMap = map[string]string{
|
var typeMap = map[string]string{
|
||||||
|
@ -69,6 +71,8 @@ var fieldNameMap = map[string]string{
|
||||||
"gv1-migration": "Gv1Migration",
|
"gv1-migration": "Gv1Migration",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var banner = "DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo"
|
||||||
|
|
||||||
func (d *DataType) fixForVersion(field, version string) {
|
func (d *DataType) fixForVersion(field, version string) {
|
||||||
response, ok := typeMap[d.Type]
|
response, ok := typeMap[d.Type]
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -111,7 +115,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for version, actions := range response.Actions {
|
for version, actions := range response.Actions {
|
||||||
inputs := ActionsTemplateInput{Version: version, Responses: false}
|
inputs := ActionsTemplateInput{Version: version, Responses: false, Banner: banner}
|
||||||
for action, a := range actions {
|
for action, a := range actions {
|
||||||
actions[action].FnName = strings.Title(action)
|
actions[action].FnName = strings.Title(action)
|
||||||
if a.Request != "" {
|
if a.Request != "" {
|
||||||
|
@ -151,6 +155,7 @@ func main() {
|
||||||
inputs := StructsTemplateInput{
|
inputs := StructsTemplateInput{
|
||||||
Version: version,
|
Version: version,
|
||||||
Types: make(map[string]*Type),
|
Types: make(map[string]*Type),
|
||||||
|
Banner: banner,
|
||||||
}
|
}
|
||||||
for typeName, t := range types {
|
for typeName, t := range types {
|
||||||
for fieldName, field := range t.Fields {
|
for fieldName, field := range t.Fields {
|
||||||
|
@ -199,6 +204,7 @@ func main() {
|
||||||
inputs := StructsTemplateInput{
|
inputs := StructsTemplateInput{
|
||||||
Version: version,
|
Version: version,
|
||||||
Types: make(map[string]*Type),
|
Types: make(map[string]*Type),
|
||||||
|
Banner: banner,
|
||||||
}
|
}
|
||||||
for typeName, t := range types {
|
for typeName, t := range types {
|
||||||
for fieldName, field := range t.Fields {
|
for fieldName, field := range t.Fields {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package {{.Version}}
|
package {{.Version}}
|
||||||
|
|
||||||
// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo
|
// {{ .Banner }}
|
||||||
|
|
||||||
import ({{if .Responses}}
|
import ({{if .Responses}}
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package {{.Version}}
|
package {{.Version}}
|
||||||
|
|
||||||
// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo
|
// {{ .Banner }}
|
||||||
|
|
||||||
{{if gt (.ImportVersions | len) 0}}
|
{{if gt (.ImportVersions | len) 0}}
|
||||||
import (
|
import (
|
||||||
{{range $version := .ImportVersions}}
|
{{range $version := .ImportVersions}}
|
||||||
|
|
Loading…
Reference in a new issue