github.com/mkideal/godep@v0.0.0-20160710170555-3c0ccb9a2415/path.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  )
     7  
     8  var cmdPath = &Command{
     9  	Name:  "path",
    10  	Short: "print GOPATH for dependency code",
    11  	Long: `
    12  Command path prints a path for use in env var GOPATH
    13  that makes available the specified version of each dependency.
    14  
    15  The printed path does not include any GOPATH value from
    16  the environment.
    17  
    18  For more about how GOPATH works, see 'go help gopath'.
    19  `,
    20  	Run:          runPath,
    21  	OnlyInGOPATH: true,
    22  }
    23  
    24  // Print the gopath that points to
    25  // the included dependency code.
    26  func runPath(cmd *Command, args []string) {
    27  	if len(args) != 0 {
    28  		cmd.UsageExit()
    29  	}
    30  	if VendorExperiment {
    31  		fmt.Fprintln(os.Stderr, "Error: GO15VENDOREXPERIMENT is enabled and the vendor/ directory is not a valid Go workspace.")
    32  		os.Exit(1)
    33  	}
    34  	gopath := prepareGopath()
    35  	fmt.Println(gopath)
    36  }