glide installation
After the installation is complete, there will be a glide.exe file in the %GOPATH%/bin directorygo get github.com/Masterminds/glide
- Configure the environment variables of glide to facilitate the use of glide commands later
Switch to the project root directory to initialize the yaml file with the glide init command
glide init
After initialization, the complete directory is as follows
glide.yaml, because there is only fmt.Println("hello world") in main.go for the time beingpackage: github.com/nickchou/glide-go import: []
lead a package test
glide get github.com/mattn/go-adodb
If the following error is reported (as shown in the figure):
Unable to export dependencies to vendor directory: Error moving files: exit status 1. output:
Solution: Find %GOPATH%/src/github.com/Masterminds/glide/path/winbug.go file, modify about 75 lines
After recompiling, copy the glide.exe file to the %GOPATH%/bin directory [Important]func CustomRename(o, n string) error { // Handking windows cases first if runtime.GOOS == "windows" { msg.Debug("Detected Windows. Moving files using windows command") //cmd := exec.Command("cmd.exe", "/c", "move", o, n) cmd := exec.Command("cmd.exe", "/c", "xcopy /s/y", o, n+"\\") //新增这一行代码 output, err := cmd.CombinedOutput() if err != nil { return fmt.Errorf("Error moving files: %s. output: %s", err, output) } return nil } else if detectWsl() { cmd := exec.Command("mv", o, n) output, err2 := cmd.CombinedOutput() msg.Debug("Detected Windows Subsystem for Linux. Removing files using subsystem command") if err2 != nil { return fmt.Errorf("Error moving files: %s. output: %s", err2, output) } return nil } return os.Rename(o, n) }
Re-import the package. If this package is used in the main function, and the package contains other project sources, it will also be downloaded. Be careful , especially if the project source is on golang.org
glide get github.com/mattn/go-adodb
Import a single package source
The directory structure for importing a single package source is as followsglide get --all-dependencies -s -v github.com/mattn/go-adodb
Import the project according to the specified version number, such as
The content of the glide.yaml file is as followsglide get github.com/go-sql-driver/mysql#v1.2
After the installation is complete, when import is actually used, the code source will be found in the vendor directory first.
Instructions for using golang package management glide under window
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=324980031&siteId=291194637
Ranking