Issue 1:
1 What version of Go are you using (go version)?

$ go version
go version go1.6 linux/amd64

2 What operating system and processor architecture are you using?

$ cat /etc/issue
Ubuntu 15.10 \n \l

$ lscpu
Architecture: x86_64
...

3 What did you do?

$ tree $GOPATH/src
├── a
│ ├── a.go
│ └── vendor
│ └── b
│ └── b.go
└── build
└── main.go

$ cat $GOPATH/src/build/main.go

package main

import (
"go/ast"
"go/build"
"go/importer"
"go/parser"
"go/token"
"go/types"
"os"
"path"
)

func panicOnErr(err error) {
if err != nil {
panic(err.Error())
}
}

func main() {
gopath := os.Getenv("GOPATH")
dir := path.Join(gopath, "src", "a")

// println("dir: " + dir)
fset := token.NewFileSet()
buildPkg, err := build.ImportDir(dir, build.ImportMode(0))

panicOnErr(err)

astFiles := []*ast.File{}

for _, filename := range buildPkg.GoFiles {
file, err := parser.ParseFile(fset, path.Join(dir, filename), nil, parser.AllErrors)
panicOnErr(err)
astFiles = append(astFiles, file)
}

for _, filename := range buildPkg.CgoFiles {
file, err := parser.ParseFile(fset, path.Join(dir, filename), nil, parser.AllErrors)
panicOnErr(err)
astFiles = append(astFiles, file)
}

typesInfo := &types.Info{
Types: make(map[ast.Expr]types.TypeAndValue),
Defs: make(map[*ast.Ident]types.Object),
Uses: make(map[*ast.Ident]types.Object),
}

var conf types.Config
conf.Importer = importer.Default()
conf.IgnoreFuncBodies = true
typesPkg, err := conf.Check(buildPkg.Name, fset, astFiles, typesInfo)

panicOnErr(err)

_ = typesPkg
}

$ cat $GOPATH/src/a/a.go

package a

import "b"

var foo = b.Foo

$ cat $GOPATH/src/a/vendor/b/b.go

package b

var Foo = "bar"

4 What did you expect to see?

Nothing (that's OK)

$ go run build/main.go

5 What did you see instead?

$ go env && go version && go run $GOPATH/src/build/main.go
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/benny/Entwicklung/testdebug/gopath"
GORACE=""
GOROOT="/home/benny/bin/go"
GOTOOLDIR="/home/benny/bin/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
go version go1.6 linux/amd64
panic: a/a.go:3:8: could not import b (can't find import: a/vendor/b)

goroutine 1 [running]:
panic(0x653760, 0xc82000ade0)
go/src/runtime/panic.go:464 +0x3e6
main.panicOnErr(0x7fb0a76aac58, 0xc82000fe00)
build/main.go:16 +0x7e
main.main()
build/main.go:56 +0x8bd
exit status 2

Further information

When installing the vendor package

$ go install $GOPATH/src/a/vendor/b

before running

$ go run $GOPATH/src/build/main.go

It runs fine as expected. After removing the build

$ rm $GOPATH/pkg/linux_amd64/a/vendor/b.a

It complains again

$ go run $GOPATH/src/build/main.go
panic: a/a.go:3:8: could not import b (can't find import: a/vendor/b)

goroutine 1 [running]:
panic(0x653760, 0xc82000ade0)
go/src/runtime/panic.go:464 +0x3e6
main.panicOnErr(0x7fb0a76aac58, 0xc82000fe00)
build/main.go:16 +0x7e
main.main()
build/main.go:56 +0x8bd
exit status 2

Probably related to #14215

Issue 2:
It is common to use go/types is as part of a go generate command

or other command line tool to introspect a Go package.

The go tool goes to some lengths to ensure that whenever

you operate on a package, it builds the source for that

package into object form before using it, so you don't

end up using symbol information that's out of date with respect

to the source.

When using go/types from a command line tool, you

don't have that luxury, and it's not necessarily appropriate

to call "go install" automatically.

I believe that a better way would be for the default

importer to use the object file data only if it's newer

than the source files, otherwise fall back to using the

source directly. Or at least it would be nice to have

that option, so that it's easy to make go generate

utilities operate on the up to date code.

I hope this could be considered before Go 1.5 as

we won't be able to change this behaviour after then.