awalterschulze / goderive

Derives and generates mundane golang functions that you do not want to maintain yourself
Apache License 2.0
1.24k stars 43 forks source link

fix for issue #60 #62

Closed jbl428 closed 3 years ago

jbl428 commented 3 years ago

Fixes #60

deriveSorted uses Strings, Float64s and Ints functions of sort package only if type of the slice element is not aliased.

There is another issue in #60. the author provided some test code.

type stringalias string

func TestSortedMapKeysTypeAliasKey(t *testing.T) {
    var m map[stringalias]string
    m = random(m).(map[stringalias]string)
    keys := deriveSortedAlias(deriveKeysForMapAliasToString(m))

deriveSortedAlias is not generated.

I have found that deriveSortedAlias never generated if the function's arg is the return value of any generated goderive function.

the following test code passes without any issue.

type stringalias string

func TestSortedMapKeysTypeAliasKey(t *testing.T) {
    keys := deriveSortedAlias([]stringalias{"a", "b"})

After some testing, I have finally found that if type alias is defined in a normal go file, there is no issue at all.

so, I move the type definitions in test/normal/*_test.go files to new types.go file.

awalterschulze commented 3 years ago

Now I really need CI back, to be able to properly review this. I hope it is okay to have a delay here, since I am moving in the next couple of weeks, so things are a bit hectic.

jbl428 commented 3 years ago

No problem. you can review this anytime you want. 😃

In the meantime, Is there anything that I can help rebuilding CI?

I have little experience of Github action, but I think I can manage somehow.

awalterschulze commented 3 years ago

I have not setup a github action myself either. If you are willing to help setup the github action, that would be amazing.

Here are some examples for setting up CI with github actions on other go projects:

What we want is to effectively do something similar to make travis Does that make sense?

jbl428 commented 3 years ago

I understand. the examples is useful for building CI. Thank you.

I have one question.

Should I close this PR and reopen it after CI is restored? I am not sure that I should request other PR about rebuilding CI and request this one after it merged.

awalterschulze commented 3 years ago

You can leave this one open. Let’s see what happens. It might be as simple as pushing one new commit to this PR to trigger the action once the action has been merged.

But also whatever is easiest for you

On Tue, 1 Jun 2021 at 06:54, Jake Son @.***> wrote:

I understand. the examples is useful for building CI. Thank you.

I have one question.

Should I close this PR and reopen it after CI is restored? I can not sure that I should request other PR about rebuilding CI and request this one after it merged.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/awalterschulze/goderive/pull/62#issuecomment-851838316, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN6YLISDAS6WNRNHGZ45WLTQRY3BANCNFSM45YMQJNQ .

jbl428 commented 3 years ago

I have added a commit of updating CI badge in Readme.md