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

Anthony/add expanders #63

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft

Anthony/add expanders #63

wants to merge 16 commits into from

Conversation

notanthony
Copy link
Contributor

@notanthony notanthony commented Jan 5, 2024

On hold for now

I made the expander code in the cone repo into a tools package for the go sdk. I used a more idiomatic way of representing generics and reflection to eliminate some of the boiler plate required.

)

const (
atTypeApp = "type.googleapis.com/c1.api.app.v1.App"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we export these const from the SDK anywhere? shouldn't we?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I exported them

}

// Use reflection to call the `GetAtType` method on an pointer receiver, func GetAtType() *string.
func GetAtTypeWithReflection[T any](input *T) *string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't this be T getAtType with type getAtType interface{ GetAtType() *string }?

Copy link
Contributor Author

@notanthony notanthony Mar 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get this error type *T is pointer to type parameter, not type parameter because:

The method set of *T does not automatically include pointer receiver methods declared on the T's concrete type A, and it does not implement interfaces that would be implemented by *A.

I cant think of a better way of doing this since I am doing this weird thing where I call both a pointer receiver function and a normal function.

@notanthony notanthony requested a review from pquerna April 1, 2024 23:03
@notanthony notanthony marked this pull request as draft April 18, 2024 18:39
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