<p dir="auto">We should simplify and stabilize the go/loader package's API.  Before that happens, there are a number of features to add and bugs to fix:</p>
<p dir="auto">Features:</p>
<ol dir="auto">
<li>
<p dir="auto">support ... patterns just like "go build" and "go list" do.  (Ideally the logic would be shared.  Russ suggested fork/execing "go list", but I don't like this approach: it uses the actual file system instead of the abstraction defined by build.Context.)</p>
</li>
<li>
<p dir="auto">Allow packages specified on the command line to use cgo.  Currently only imported packages are subject to cgo preprocessing.</p>
</li>
<li>
<p dir="auto">Support pkg-config.</p>
</li>
</ol>
<p dir="auto">API simplifications:</p>
<ol start="4" dir="auto">
<li>
<p dir="auto">The public fields of loader.Program are sometimes annoying to use.  Study existing clients and come up with something more convenient.</p>
</li>
<li>
<p dir="auto">Update the go/types tutorial at <a href="https://github.com/golang/example/tree/master/gotypes">https://github.com/golang/example/tree/master/gotypes</a>.</p>
</li>
</ol>
<p dir="auto">Once this is done, we should use go/loader in tools such as golint, govet and stringer.</p>
<p dir="auto">cc: <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/griesemer/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/griesemer">@griesemer</a></p>
<p dir="auto">Do you think <code class="notranslate">short</code> is necessary here for 3 times string copy?,<br>
Maybe we could just <code class="notranslate">file = file[i+1:]</code> ?<br>
I issue this because it is in the <code class="notranslate">l.mu.Lock()</code>:)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="https://github.com/golang/go/blob/master/src/log/log.go#L121
    if l.flag&amp;(Lshortfile|Llongfile) != 0 {
        if l.flag&amp;Lshortfile != 0 {
            short := file
            for i := len(file) - 1; i &gt; 0; i-- {
                if file[i] == '/' {
                    short = file[i+1:]
                    break
                }
            }
            file = short
        }"><pre class="notranslate"><code class="notranslate">https://github.com/golang/go/blob/master/src/log/log.go#L121
    if l.flag&amp;(Lshortfile|Llongfile) != 0 {
        if l.flag&amp;Lshortfile != 0 {
            short := file
            for i := len(file) - 1; i &gt; 0; i-- {
                if file[i] == '/' {
                    short = file[i+1:]
                    break
                }
            }
            file = short
        }
</code></pre></div>