Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@defaulterrr
Copy link
Contributor

@defaulterrr defaulterrr commented Feb 17, 2023

I noticed an issue about missing support for generics and figured i'd try to solve it

This PR adds support for generic interfaces by extending the template and analysis of an ast tree

What i did:

  • Bump Go version to 1.18 to add generics support in ast/ packages
  • Extend interfaces in some functions to not only reflect the name of the interfaces, but also it's type parameters
  • Added custom functions to template engine to generate type param declarations and references. To provide compatibility with non-generic code these functions return empty strings in no type params are present, so there is no difference for existing code. I figured this to be the easiest way as underlying gen-engine does not support generics (as far as i could tell, it does not have corresponding fields in structs and is based on go1.17)
  • Extended the template to use those functions and generate compilable Go code

Additional changes:

  • Added test cases for interfaces (tested that those failed on v3.0.10
  • Minor format changes for existing test cases

Closes #63

@hexdigest hexdigest merged commit 2e8dde8 into gojuno:master Feb 17, 2023
@hexdigest
Copy link
Collaborator

Hi @defaulterrr

This is an awesome PR, thanks for your contribution!

@hexdigest
Copy link
Collaborator

It is available now in v3.1.1

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.

Doesn't work on packages with generics

2 participants