Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare #83

Open
awalterschulze opened this issue Mar 18, 2015 · 0 comments
Open

Compare #83

awalterschulze opened this issue Mar 18, 2015 · 0 comments

Comments

@awalterschulze
Copy link

Hi

Would you be interested in having a compare typewriter?

This would basically just compare each field for a type from top to bottom.
When a field is found with a compare != 0 then that value is returned.

Here is some example generated code.

func (this *MyType) Compare(that *MyType) int {
  if this.Field1 != that.Field1 {
    if this.Field1 < that.Field1 {
      return -1
    }
    return 1
  }
  if c := bytes.Compare(this.Field2, that.Field2); c != 0 {
    return c
  }
  if c := this.Field3.Compare(that.Field3); c != 0 {
    return c
  }
  return 0
}

Would you be interested in such a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant