<pre class="notranslate">To reproduce, create the following three files:

testit.go

    package testit

extern_test.go:

    package testit_test

    import (
        "code.google.com/p/rog-go/testit"
    )

    func init() {
        testit.Register()
        unused
    }

intern_test.go:

    package testit
    
    import "testing"
    
    var registered bool
    
    func Register() {
        registered = true
    }
    
    func TestPackage(t *testing.T) {
        if !registered {
            t.Fatal("registry never called")
        }
    }

Running the tests gives the error "registry never called",
indicating that the code in extern_test.go is never run.
Moreover, it's not even compiled - there's no error from
the unused variable.

While it may look contrived, the above configuration mirrors the way
that tests are registered with the popular gocheck testing
package - tests that were previously run correctly may now
be silently skipped.

I have verified that this is a regression since Go 1.2.2.

FWIW, there is an easy workaround (define TestPackage in the external
test file) but it might be better to avoid the regression.</pre>
<p dir="auto">hi,</p>
<p dir="auto">with the upcoming go-1.5 and the import of (a modified version of) the x/tools/go/types package into the stdlib, <code class="notranslate">golang.org/x/tools/go/loader</code> needs to be updated.</p>
<p dir="auto">the following program will fail to compile:</p>
<div class="highlight highlight-source-go notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="package main

import (
    &quot;fmt&quot;
    &quot;go/build&quot;
    &quot;go/token&quot;
    &quot;go/types&quot;
    &quot;log&quot;
    &quot;os&quot;

    &quot;golang.org/x/tools/go/loader&quot;
)

func main() {
    path := os.Args[1]
    fmt.Printf(&quot;&gt;&gt;&gt; inspecting [%s]...\n&quot;, path)

    cwd, err := os.Getwd()
    if err != nil {
        log.Panicf(&quot;error: %v\n&quot;, err)
    }

    pkg, err := build.Import(path, cwd, 0)
    if err != nil {
        log.Panicf(&quot;error: %v\n&quot;, err)
    }

    conf := loader.Config{
        Fset: token.NewFileSet(),
    }

    prog, err := conf.Load()
    if err != nil {
        log.Panicf(&quot;error: %v\n&quot;, err)
    }

    var p *types.Package = prog.Created[0].Pkg
    fmt.Printf(&quot;pkg=%v\n&quot;, p)
}"><pre class="notranslate"><span class="pl-k">package</span> main

<span class="pl-k">import</span> (
    <span class="pl-s">"fmt"</span>
    <span class="pl-s">"go/build"</span>
    <span class="pl-s">"go/token"</span>
    <span class="pl-s">"go/types"</span>
    <span class="pl-s">"log"</span>
    <span class="pl-s">"os"</span>

    <span class="pl-s">"golang.org/x/tools/go/loader"</span>
)

<span class="pl-k">func</span> <span class="pl-en">main</span>() {
    <span class="pl-s1">path</span> <span class="pl-c1">:=</span> <span class="pl-s1">os</span>.<span class="pl-c1">Args</span>[<span class="pl-c1">1</span>]
    <span class="pl-s1">fmt</span>.<span class="pl-en">Printf</span>(<span class="pl-s">"&gt;&gt;&gt; inspecting [%s]...<span class="pl-cce">\n</span>"</span>, <span class="pl-s1">path</span>)

    <span class="pl-s1">cwd</span>, <span class="pl-s1">err</span> <span class="pl-c1">:=</span> <span class="pl-s1">os</span>.<span class="pl-en">Getwd</span>()
    <span class="pl-k">if</span> <span class="pl-s1">err</span> <span class="pl-c1">!=</span> <span class="pl-c1">nil</span> {
        <span class="pl-s1">log</span>.<span class="pl-en">Panicf</span>(<span class="pl-s">"error: %v<span class="pl-cce">\n</span>"</span>, <span class="pl-s1">err</span>)
    }

    <span class="pl-s1">pkg</span>, <span class="pl-s1">err</span> <span class="pl-c1">:=</span> <span class="pl-s1">build</span>.<span class="pl-en">Import</span>(<span class="pl-s1">path</span>, <span class="pl-s1">cwd</span>, <span class="pl-c1">0</span>)
    <span class="pl-k">if</span> <span class="pl-s1">err</span> <span class="pl-c1">!=</span> <span class="pl-c1">nil</span> {
        <span class="pl-s1">log</span>.<span class="pl-en">Panicf</span>(<span class="pl-s">"error: %v<span class="pl-cce">\n</span>"</span>, <span class="pl-s1">err</span>)
    }

    <span class="pl-s1">conf</span> <span class="pl-c1">:=</span> loader.<span class="pl-smi">Config</span>{
        <span class="pl-c1">Fset</span>: <span class="pl-s1">token</span>.<span class="pl-en">NewFileSet</span>(),
    }

    <span class="pl-s1">prog</span>, <span class="pl-s1">err</span> <span class="pl-c1">:=</span> <span class="pl-s1">conf</span>.<span class="pl-en">Load</span>()
    <span class="pl-k">if</span> <span class="pl-s1">err</span> <span class="pl-c1">!=</span> <span class="pl-c1">nil</span> {
        <span class="pl-s1">log</span>.<span class="pl-en">Panicf</span>(<span class="pl-s">"error: %v<span class="pl-cce">\n</span>"</span>, <span class="pl-s1">err</span>)
    }

    <span class="pl-k">var</span> <span class="pl-s1">p</span> <span class="pl-c1">*</span>types.<span class="pl-smi">Package</span> <span class="pl-c1">=</span> <span class="pl-s1">prog</span>.<span class="pl-c1">Created</span>[<span class="pl-c1">0</span>].<span class="pl-c1">Pkg</span>
    <span class="pl-s1">fmt</span>.<span class="pl-en">Printf</span>(<span class="pl-s">"pkg=%v<span class="pl-cce">\n</span>"</span>, <span class="pl-s1">p</span>)
}</pre></div>
<p dir="auto">with the following error:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="sh&gt; go run foo.go github.com/go-python/gopy/_examples/hi
# command-line-arguments
./foo.go:39: cannot use prog.Created[0].Pkg (type *&quot;golang.org/x/tools/go/types&quot;.Package) as type *&quot;go/types&quot;.Package in assignment"><pre class="notranslate">sh<span class="pl-k">&gt;</span> go run foo.go github.com/go-python/gopy/_examples/hi
<span class="pl-c"><span class="pl-c">#</span> command-line-arguments</span>
./foo.go:39: cannot use prog.Created[0].Pkg (type <span class="pl-k">*</span><span class="pl-s"><span class="pl-pds">"</span>golang.org/x/tools/go/types<span class="pl-pds">"</span></span>.Package) as <span class="pl-c1">type</span> <span class="pl-k">*</span><span class="pl-s"><span class="pl-pds">"</span>go/types<span class="pl-pds">"</span></span>.Package <span class="pl-k">in</span> assignment</pre></div>