go/loader: fix CreateFromFilenames example

The "sort" package is no longer quite as low-level as it once was.

Change-Id: Ic62d780841ef1172f65d4c00ec500994f94cb4b7
Reviewed-on: https://go-review.googlesource.com/30931
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Alan Donovan 2016-10-12 11:10:48 -04:00
parent 41f4ee4e59
commit 992f6f9bcc
1 changed files with 7 additions and 5 deletions

View File

@ -92,10 +92,12 @@ func ExampleConfig_FromArgs() {
// This example creates and type-checks a single package (without tests)
// from a list of filenames, and loads all of its dependencies.
// (The input files are actually only a small part of the math/cmplx package.)
func ExampleConfig_CreateFromFilenames() {
var conf loader.Config
filename := filepath.Join(runtime.GOROOT(), "src/container/heap/heap.go")
conf.CreateFromFilenames("container/heap", filename)
conf.CreateFromFilenames("math/cmplx",
filepath.Join(runtime.GOROOT(), "src/math/cmplx/abs.go"),
filepath.Join(runtime.GOROOT(), "src/math/cmplx/sin.go"))
prog, err := conf.Load()
if err != nil {
log.Fatal(err)
@ -103,10 +105,10 @@ func ExampleConfig_CreateFromFilenames() {
printProgram(prog)
// Output:
// created: [container/heap]
// created: [math/cmplx]
// imported: []
// initial: [container/heap]
// all: [container/heap sort]
// initial: [math/cmplx]
// all: [math math/cmplx unsafe]
}
// In the examples below, for stability, the chosen packages are