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

Request to add features that can suppress unexported fields #121

Open
flw-cn opened this issue Feb 4, 2020 · 1 comment · May be fixed by #122
Open

Request to add features that can suppress unexported fields #121

flw-cn opened this issue Feb 4, 2020 · 1 comment · May be fixed by #122

Comments

@flw-cn
Copy link

flw-cn commented Feb 4, 2020

Sometimes I want the data structure I get from Dump () as I actually see it. This can be very useful for debugging APIs. I don't want to see data that I can't access at all.

I'm not sure if anyone mentioned something similar before. I tried searching but didn't find it.

Anyway, I implemented this on my fork and it seems to work fine. So I sent you a PR, I hope you can consider whether to merge or re-implement it by other means.

Thank you in advance.

@flw-cn flw-cn linked a pull request Feb 4, 2020 that will close this issue
@nf-brentsaner
Copy link

I'd like to +1 this but for a different use case; child struct types of a parent struct sometimes associate with the parent via an unexported field. Sometimes these parents are huge.

For example,

type AVeryLargeThing struct {
	// ...
	RelatedThings []*SmallThing
	// ...
}

type SmallThing struct {
	Foo string
	Bar *int
	parentThing *AVeryLargeThing
}

If I want to dump a SmallThing, I end up getting parentThing in the process. In the case of e.g. things containing tls.Configs, etc. in unexported fields this can get quite large, and one is left either marshaling SmallThing to a more text-friendly representation (e.g. JSON) or explicitly print/dump/logging each exported field explicitly just to avoid the unexported field.

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 a pull request may close this issue.

2 participants