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

No way to find underlying type of pointer or array #237

Closed
FlummoxTheMagnificent opened this issue Apr 11, 2024 · 1 comment
Closed

No way to find underlying type of pointer or array #237

FlummoxTheMagnificent opened this issue Apr 11, 2024 · 1 comment

Comments

@FlummoxTheMagnificent
Copy link

There are functions in types, IsPointer() and IsArray(), that return whether or not the provided type is a pointer or array, respectively. However, there is no way to know what the pointer is pointing to or what the array is storing, which makes working with them incredibly difficult. item.Type().(types.PointerType).ElemType and item.Type().(types.ArrayType).ElemType should work, but they don't, because the Go compiler won't allow the type assertion:

impossible type assertion: item.Type().(types.PointerType)
types.PointerType does not implement types.Type (method Equal has pointer receiver)

Please fix this; it is incredibly difficult to create pointers and arrays currently.

@FlummoxTheMagnificent
Copy link
Author

Can cast item to pointer, case the pointer to an array, and dereference again, which works for some reason?

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