-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: add preliminary support for vendor directories
When GO15VENDOREXPERIMENT=1 is in the environment, this CL changes the resolution of import paths according to the Go 1.5 vendor proposal: If there is a source directory d/vendor, then, when compiling a source file within the subtree rooted at d, import "p" is interpreted as import "d/vendor/p" if that exists. When there are multiple possible resolutions, the most specific (longest) path wins. The short form must always be used: no import path can contain “/vendor/” explicitly. Import comments are ignored in vendored packages. The goal of these changes is to allow authors to vendor (copy) external packages into their source trees without any modifications to the code. This functionality has been achieved in tools like godep, nut, and gb by requiring GOPATH manipulation. This alternate directory-based approach eliminates the need for GOPATH manipulation and in keeping with the go command's use of directory layout-based configuration. The flag allows experimentation with these vendoring semantics once Go 1.5 is released, without forcing them on by default. If the experiment is deemed a success, the flag will default to true in Go 1.6 and then be removed in Go 1.7. For more details, see the original proposal by Keith Rarick at https://groups.google.com/d/msg/golang-dev/74zjMON9glU/dGhnoi2IMzsJ. Change-Id: I2c6527e777d14ac6dc43c53e4b3ff24f3279216e Reviewed-on: https://go-review.googlesource.com/10923 Reviewed-by: Andrew Gerrand <[email protected]>
- Loading branch information
Showing
17 changed files
with
403 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package vend | ||
|
||
import _ "r" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package vend | ||
|
||
import _ "p" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"strings" // really ../vendor/strings | ||
) | ||
|
||
func main() { | ||
fmt.Printf("%s\n", strings.Msg) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package main | ||
|
||
import ( | ||
"strings" // really ../vendor/strings | ||
"testing" | ||
) | ||
|
||
func TestMsgInternal(t *testing.T) { | ||
if strings.Msg != "hello, world" { | ||
t.Fatal("unexpected msg: %v", strings.Msg) | ||
} | ||
} |
Oops, something went wrong.