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

Fix string aliases in deriveCompare #86

Merged
merged 1 commit into from
Jun 20, 2024
Merged

Fix string aliases in deriveCompare #86

merged 1 commit into from
Jun 20, 2024

Conversation

gavv
Copy link
Contributor

@gavv gavv commented Jun 3, 2024

Thanks for sharing this tool.

I've encountered a bug: if a field is a type alias to string, generated compare function will have this:

	if c := strings.Compare(this.Foo, that.Foo); c != 0 {
		return c
	}

which doesn't compile:

cannot use this.Foo (variable of type StringAlias) as string value in argument to strings.Compare

This PR fixes it by changing the generated code to:

	if c := strings.Compare(string(this.Foo), string(that.Foo)); c != 0 {
		return c
	}

@awalterschulze awalterschulze merged commit f4ac349 into awalterschulze:main Jun 20, 2024
1 check passed
@awalterschulze
Copy link
Owner

Thank you so much for the fix and unit test <3
Sorry for the long wait

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

Successfully merging this pull request may close these issues.

2 participants