NordSecurity / uniffi-bindgen-go

Uniffi bindings generator for Golang
Mozilla Public License 2.0
65 stars 18 forks source link

Fix ErrorTemplate for variants with empty fields #14

Closed bancek closed 10 months ago

bancek commented 10 months ago

I've tested this generator with my 800 line UDL file and there was just one bug. Everything else worked without any problems.

If there is a variant without fields for an interface error, the template adds an extra comma.

Example UDL:

[Error]
interface ValidationError {
  InvalidUser(i32 user_id);
  InvalidMessage(string message);
  InvalidUserAndMessage(i32 user_id, string message);
  UnknownError();
};

Generated code (before this fix):

func (err ValidationErrorUnknownError) Error() string {
    return fmt.Sprint("UnknownError",
        ,
    )
}

Thanks for this awesome generator.