Understanding the concept of vendoring in Go 1.6 can be challenging. Let's break down a common scenario and provide a solution to assist with importing files using the new vendor feature.
Issue: Despite following documentation and researching online, an individual is unable to import packages using the vendor directory in Go 1.6.
Here's a sample project structure:
. └── src ├── main.go └── vendor └── github.com └── zenazn └── goji ├── ...
And the sole file in the project, main.go:
<code class="go">import ( "github.com/zenazn/goji" "github.com/zenazn/goji/web" )</code>
Environment Variables:
<code class="Bash">export GOPATH=~/.go export GOBIN=$GOPATH/bin export PATH=$PATH:/usr/local/opt/go/libexec/bin:$GOBIN</code>
Attempted Build Commands:
Solution:
To resolve this, it's crucial to understand the way Go tools handle source code and GOPATH. To build a Go program:
Refer to the official documentation at https://golang.org/doc/code.html for a comprehensive understanding of these concepts.
The above is the detailed content of Why Can\'t I Import Packages from My Vendor Directory in Go 1.6?. For more information, please follow other related articles on the PHP Chinese website!