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

x/tools/packages: IgnoreFuncBodies implementation and comment mismatch #34806

Open
zhangyoufu opened this issue Oct 10, 2019 · 0 comments

Comments

@zhangyoufu
Copy link

commented Oct 10, 2019

https://github.com/golang/tools/blob/567d1c21dc5f922038933aa862c0719a9768eb83/go/packages/packages.go#L827-L830

// Type-check bodies of functions only in non-initial packages.
// Example: for import graph A->B->C and initial packages {A,C},
// we can ignore function bodies in B.
IgnoreFuncBodies: ld.Mode&NeedDeps == 0 && !lpkg.initial,

The comment and the given example is self-contradictory. The implementation is actually type-check bodies of functions only in initial packages.


For my use case, I would appreciate if IgnoreFuncBodies could be somehow controlled by packages.Config.

I have a script (invoked by go generate) parsing source code, harvesting struct definition and generating serialization-related code for those structs. Due to lack of serialization-related code, the type-checking for function bodies always fail because those structs does not implement my serialization interface yet.

I don't have any assertions like var _ MySerializationInterface = MyStruct{}. So as long as I can turn IgnoreFuncBodies on, everything works for me.

@gopherbot gopherbot added this to the Unreleased milestone Oct 10, 2019
@gopherbot gopherbot added the Tools label Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.