Some questions on using the "golang.org/x/tools/go/packages" package

158 views
Skip to first unread message

T L

unread,
Nov 23, 2019, 10:46:27 AM11/23/19
to golang-nuts
The packages.Config.ParseFileParseFile docs (https://godoc.org/golang.org/x/tools/go/packages#Config) says

    // An application may supply a custom implementation of ParseFile
    // to change the effective file contents or the behavior of the parser,
    // or to modify the syntax tree. For example, selectively eliminating
    // unwanted function bodies can significantly accelerate type checking.

But how to exactly do to avoid parsing function bodies? And how to set the go/types.Config.IgnoreFuncBodies
to false when calling packages.Load() to avoid checking function bodies? I failed to find the option to set it.


The packages.Config.Tests docs says

    // If Tests is set, the loader includes not just the packages
    // matching a particular pattern but also any related test packages,
    // including test-only variants of the package and the test executable.
    //
    // For example, when using the go command, loading "fmt" with Tests=true
    // returns four packages, with IDs "fmt" (the standard package),
    // "fmt [fmt.test]" (the package as compiled for the test),
    // "fmt_test" (the test functions from source files in package fmt_test),
    // and "fmt.test" (the test binary).

What do the "the package as compiled for the test" and "the test binary" mean?

Paul Jolly

unread,
Nov 23, 2019, 10:51:32 AM11/23/19
to T L, golang-nuts

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/f4116dc3-9c45-4a28-85d9-d4690e5c1eea%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages