diff --git a/signald/client-protocol/v1/errors.go b/signald/client-protocol/v1/errors.go index 9778bd6..0cf7335 100644 --- a/signald/client-protocol/v1/errors.go +++ b/signald/client-protocol/v1/errors.go @@ -1,5 +1,7 @@ package v1 +// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo + import ( "encoding/json" "fmt" @@ -7,209 +9,207 @@ import ( 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 { switch response.ErrorType { case "AccountAlreadyVerifiedError": result := AccountAlreadyVerifiedError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "AccountHasNoKeysError": result := AccountHasNoKeysError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "AccountLockedError": result := AccountLockedError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "CaptchaRequiredError": result := CaptchaRequiredError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "FingerprintVersionMismatchError": result := FingerprintVersionMismatchError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "GroupLinkNotActiveError": result := GroupLinkNotActiveError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "GroupNotActiveError": result := GroupNotActiveError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "GroupVerificationError": result := GroupVerificationError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "InternalError": result := InternalError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "InvalidAttachmentError": result := InvalidAttachmentError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "InvalidBase64Error": result := InvalidBase64Error{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "InvalidFingerprintError": result := InvalidFingerprintError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "InvalidGroupError": result := InvalidGroupError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "InvalidGroupStateError": result := InvalidGroupStateError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "InvalidInviteURIError": result := InvalidInviteURIError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "InvalidProxyError": result := InvalidProxyError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "InvalidRecipientError": result := InvalidRecipientError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "InvalidRequestError": result := InvalidRequestError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "NoKnownUUIDError": result := NoKnownUUIDError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "NoSendPermissionError": result := NoSendPermissionError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "NoSuchAccountError": result := NoSuchAccountError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "NoSuchSessionError": result := NoSuchSessionError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "OwnProfileKeyDoesNotExistError": result := OwnProfileKeyDoesNotExistError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "ProfileUnavailableError": result := ProfileUnavailableError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "ServerNotFoundError": result := ServerNotFoundError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "UnknownGroupError": result := UnknownGroupError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "UnknownIdentityKeyError": result := UnknownIdentityKeyError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "UntrustedIdentityError": result := UntrustedIdentityError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } return result case "UserAlreadyExistsError": result := UserAlreadyExistsError{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } diff --git a/tools/generator/errors.go.tmpl b/tools/generator/errors.go.tmpl index 69e2cdc..2ccdaeb 100644 --- a/tools/generator/errors.go.tmpl +++ b/tools/generator/errors.go.tmpl @@ -1,5 +1,7 @@ package {{.Version}} +// {{ .Banner }} + import ( "encoding/json" "fmt" @@ -7,13 +9,11 @@ import ( 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 { switch response.ErrorType { {{ range $structName, $type := .Types }} case "{{ $structName }}": result := {{ $structName }}{} - err := json.Unmarshal(response.Error, result) + err := json.Unmarshal(response.Error, &result) if err != nil { return err } diff --git a/tools/generator/main.go b/tools/generator/main.go index a68a78a..cda73a1 100644 --- a/tools/generator/main.go +++ b/tools/generator/main.go @@ -41,12 +41,14 @@ type StructsTemplateInput struct { Types map[string]*Type Version string ImportVersions []string + Banner string } type ActionsTemplateInput struct { Actions map[string]*Action Version string Responses bool + Banner string } var typeMap = map[string]string{ @@ -69,6 +71,8 @@ var fieldNameMap = map[string]string{ "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) { response, ok := typeMap[d.Type] if ok { @@ -111,7 +115,7 @@ func main() { } 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 { actions[action].FnName = strings.Title(action) if a.Request != "" { @@ -151,6 +155,7 @@ func main() { inputs := StructsTemplateInput{ Version: version, Types: make(map[string]*Type), + Banner: banner, } for typeName, t := range types { for fieldName, field := range t.Fields { @@ -199,6 +204,7 @@ func main() { inputs := StructsTemplateInput{ Version: version, Types: make(map[string]*Type), + Banner: banner, } for typeName, t := range types { for fieldName, field := range t.Fields { diff --git a/tools/generator/requests.go.tmpl b/tools/generator/requests.go.tmpl index d706259..fe08ac1 100644 --- a/tools/generator/requests.go.tmpl +++ b/tools/generator/requests.go.tmpl @@ -1,6 +1,6 @@ package {{.Version}} -// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo +// {{ .Banner }} import ({{if .Responses}} "encoding/json" diff --git a/tools/generator/structs.go.tmpl b/tools/generator/structs.go.tmpl index e8091a2..ba5255a 100644 --- a/tools/generator/structs.go.tmpl +++ b/tools/generator/structs.go.tmpl @@ -1,6 +1,7 @@ package {{.Version}} -// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo +// {{ .Banner }} + {{if gt (.ImportVersions | len) 0}} import ( {{range $version := .ImportVersions}}