github.com/xkeyideal/glide@v0.0.0-20171121052037-a806f0aaeda0/README.md (about) 1 The repo mirror from [Masterminds/glide](https://github.com/Masterminds/glide) 2 3 ## Improvements 4 5 1. Fix error: Windows Operate System Unable to export dependencies to vendor directory. 6 2. Fix mirror export subpackages to vendor directory is wrong. 7 8 ## Bug 1 9 10 Fix error: Windows Operate System Unable to export dependencies to vendor directory. 11 12 Because Windows Filesystem Permission after fetching packages will unable to export. 13 14 Merge this pull request [#889](https://github.com/Masterminds/glide/pull/889/commits/cc37dc711a3191c2b91b01b9593c685660eeb9af) 15 16 ## Bug 2 17 18 Because of China's GFW, the Chinese programmers can't fetch some `golang.org` packages, such as `golang.org/x/sys` 19 20 Fortunately, this `golang.org` packages mirror at `github.com/golang/...`, then use `glide mirror set` command set the mirror. 21 22 `glide mirror set https://golang.org/x/sys https://github.com/golang/sys` 23 24 But when we need fetch subpackages will be any wrong. 25 26 For example: 27 28 We need `go get golang.org/x/sys/unix`, use glide should be: 29 30 1. glide mirror set https://golang.org/x/sys/unix https://github.com/golang/sys 31 2. glide get golang.org/x/sys/unix 32 33 But the result is `glide` will export the sys directory to golang.org/x/sys/unix. 34 35 We will see `golang.org/x/sys/unix/unix`, `golang.org/x/sys/unix/plan9`, `golang.org/x/sys/unix/windows`. 36 37 Some people maybe set mirror like this, `glide mirror set https://golang.org/x/sys/unix https://github.com/golang/sys/unix`, 38 then `glide` will report `Cannot detect VCS`. 39 40 So my solution, modify [Masterminds/glide](https://github.com/Masterminds/glide) mirrors Package code. 41 42 `glide mirror` command add `--base` option, set the export directory. 43 44 1. glide mirror set https://golang.org/x/sys/unix https://github.com/golang/sys --base golang.org/x/sys 45 2. glide get golang.org/x/sys/unix 46 47 The `mirrors.yaml` file will be: 48 49 ```yaml 50 repos: 51 - original: https://golang.org/x/crypto 52 repo: https://github.com/golang/crypto 53 - original: https://golang.org/x/crypto/acme/autocert 54 repo: https://github.com/golang/crypto 55 base: golang.org/x/crypto 56 - original: https://golang.org/x/sys/unix 57 repo: https://github.com/golang/sys 58 base: golang.org/x/sys 59 ``` 60 61 You also can execute `glide mirror list` command see the base option. 62 63 So the result is correct. 64 65 ## Finally 66 67 I'm Chinese, I hate China's GFW. Forgive my poor English. 68 69 能读懂中文的请转这里,README_CN.md 70 71 # Glide: Vendor Package Management for Golang 72 73 ![glide logo](https://glide.sh/assets/logo-small.png) 74 75 Are you used to tools such as Cargo, npm, Composer, Nuget, Pip, Maven, Bundler, 76 or other modern package managers? If so, Glide is the comparable Go tool. 77 78 *Manage your vendor and vendored packages with ease.* Glide is a tool for 79 managing the `vendor` directory within a Go package. This feature, first 80 introduced in Go 1.5, allows each package to have a `vendor` directory 81 containing dependent packages for the project. These vendor packages can be 82 installed by a tool (e.g. glide), similar to `go get` or they can be vendored and 83 distributed with the package. 84 85 [![Build Status](https://travis-ci.org/Masterminds/glide.svg)](https://travis-ci.org/Masterminds/glide) 86 [![Build status](https://ci.appveyor.com/api/projects/status/3pl4ytgdlfj852li?svg=true&passingText=windows%20build%20passing&failingText=windows%20build%20failing)](https://ci.appveyor.com/project/mattfarina/glide-a8xtg) 87 [![Go Report Card](https://goreportcard.com/badge/github.com/Masterminds/glide)](https://goreportcard.com/report/github.com/Masterminds/glide) [![GoDoc](https://godoc.org/github.com/Masterminds/glide?status.svg)](https://godoc.org/github.com/Masterminds/glide) [![Documentation Status](https://readthedocs.org/projects/glide/badge/?version=stable)](http://glide.readthedocs.org/en/stable/?badge=stable) [![Documentation Status](https://readthedocs.org/projects/glide/badge/?version=latest)](http://glide.readthedocs.org/en/latest/?badge=latest) [![Join the chat at https://gitter.im/Masterminds/glide](https://badges.gitter.im/Masterminds/glide.svg)](https://gitter.im/Masterminds/glide?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 88 89 ### Golang Dep 90 91 The Go community now has the [dep](https://github.com/golang/dep) project to 92 manage dependencies. Please consider trying to migrate from Glide to dep. If there 93 is an issue preventing you from migrating please file an issue with dep so the 94 problem can be corrected. Glide will continue to be supported for some time but 95 is considered to be in a state of support rather than active feature development. 96 97 ### Features 98 99 * Ease dependency management 100 * Support **versioning packages** including [Semantic Versioning 101 2.0.0](http://semver.org/) support. Any constraint the [`github.com/Masterminds/semver`](https://github.com/Masterminds/semver) 102 package can parse can be used. 103 * Support **aliasing packages** (e.g. for working with github forks) 104 * Remove the need for munging import statements 105 * Work with all of the `go` tools 106 * Support the VCS tools that Go supports: 107 - git 108 - bzr 109 - hg 110 - svn 111 * Support custom local and global plugins (see docs/plugins.md) 112 * Repository caching and data caching for improved performance. 113 * Flatten dependencies resolving version differences and avoiding the inclusion 114 of a package multiple times. 115 * Manage and install dependencies on-demand or vendored in your version control 116 system. 117 118 ## How It Works 119 120 Glide scans the source code of your application or library to determine the needed 121 dependencies. To determine the versions and locations (such as aliases for forks) 122 Glide reads a `glide.yaml` file with the rules. With this information Glide retrieves 123 needed dependencies. 124 125 When a dependent package is encountered its imports are scanned to determine 126 dependencies of dependencies (transitive dependencies). If the dependent project 127 contains a `glide.yaml` file that information is used to help determine the 128 dependency rules when fetching from a location or version to use. Configuration 129 from Godep, GB, GOM, and GPM is also imported. 130 131 The dependencies are exported to the `vendor/` directory where the `go` tools 132 can find and use them. A `glide.lock` file is generated containing all the 133 dependencies, including transitive ones. 134 135 The `glide init` command can be use to setup a new project, `glide update` 136 regenerates the dependency versions using scanning and rules, and `glide install` 137 will install the versions listed in the `glide.lock` file, skipping scanning, 138 unless the `glide.lock` file is not found in which case it will perform an update. 139 140 A project is structured like this: 141 142 ``` 143 - $GOPATH/src/myProject (Your project) 144 | 145 |-- glide.yaml 146 | 147 |-- glide.lock 148 | 149 |-- main.go (Your main go code can live here) 150 | 151 |-- mySubpackage (You can create your own subpackages, too) 152 | | 153 | |-- foo.go 154 | 155 |-- vendor 156 |-- github.com 157 | 158 |-- Masterminds 159 | 160 |-- ... etc. 161 ``` 162 163 *Take a look at [the Glide source code](http://github.com/Masterminds/glide) 164 to see this philosophy in action.* 165 166 ## Install 167 168 The easiest way to install the latest release on Mac or Linux is with the following script: 169 170 ``` 171 curl https://glide.sh/get | sh 172 ``` 173 174 On Mac OS X you can also install the latest release via [Homebrew](https://github.com/Homebrew/homebrew): 175 176 ``` 177 $ brew install glide 178 ``` 179 180 On Ubuntu Precise (12.04), Trusty (14.04), Wily (15.10) or Xenial (16.04) you can install from our PPA: 181 182 ``` 183 sudo add-apt-repository ppa:masterminds/glide && sudo apt-get update 184 sudo apt-get install glide 185 ``` 186 187 On Ubuntu Zesty (17.04) the package is called `golang-glide`. 188 189 [Binary packages](https://github.com/Masterminds/glide/releases) are available for Mac, Linux and Windows. 190 191 For a development version it is also possible to `go get github.com/Masterminds/glide`. 192 193 To build from source you can: 194 195 1. Clone this repository into `$GOPATH/src/github.com/Masterminds/glide` and 196 change directory into it 197 2. If you are using Go 1.5 ensure the environment variable GO15VENDOREXPERIMENT is set, for 198 example by running `export GO15VENDOREXPERIMENT=1`. In Go 1.6 it is enabled by default and 199 in Go 1.7 it is always enabled without the ability to turn it off. 200 3. Run `make build` 201 202 This will leave you with `./glide`, which you can put in your `$PATH` if 203 you'd like. (You can also take a look at `make install` to install for 204 you.) 205 206 The Glide repo has now been configured to use glide to 207 manage itself, too. 208 209 ## Usage 210 211 ``` 212 $ glide create # Start a new workspace 213 $ open glide.yaml # and edit away! 214 $ glide get github.com/Masterminds/cookoo # Get a package and add to glide.yaml 215 $ glide install # Install packages and dependencies 216 # work, work, work 217 $ go build # Go tools work normally 218 $ glide up # Update to newest versions of the package 219 ``` 220 221 Check out the `glide.yaml` in this directory, or examples in the `docs/` 222 directory. 223 224 ### glide create (aliased to init) 225 226 Initialize a new workspace. Among other things, this creates a `glide.yaml` file 227 while attempting to guess the packages and versions to put in it. For example, 228 if your project is using Godep it will use the versions specified there. Glide 229 is smart enough to scan your codebase and detect the imports being used whether 230 they are specified with another package manager or not. 231 232 ``` 233 $ glide create 234 [INFO] Generating a YAML configuration file and guessing the dependencies 235 [INFO] Attempting to import from other package managers (use --skip-import to skip) 236 [INFO] Scanning code to look for dependencies 237 [INFO] --> Found reference to github.com/Masterminds/semver 238 [INFO] --> Found reference to github.com/Masterminds/vcs 239 [INFO] --> Found reference to github.com/codegangsta/cli 240 [INFO] --> Found reference to gopkg.in/yaml.v2 241 [INFO] Writing configuration file (glide.yaml) 242 [INFO] Would you like Glide to help you find ways to improve your glide.yaml configuration? 243 [INFO] If you want to revisit this step you can use the config-wizard command at any time. 244 [INFO] Yes (Y) or No (N)? 245 n 246 [INFO] You can now edit the glide.yaml file. Consider: 247 [INFO] --> Using versions and ranges. See https://glide.sh/docs/versions/ 248 [INFO] --> Adding additional metadata. See https://glide.sh/docs/glide.yaml/ 249 [INFO] --> Running the config-wizard command to improve the versions in your configuration 250 ``` 251 252 The `config-wizard`, noted here, can be run here or manually run at a later time. 253 This wizard helps you figure out versions and ranges you can use for your 254 dependencies. 255 256 ### glide config-wizard 257 258 This runs a wizard that scans your dependencies and retrieves information on them 259 to offer up suggestions that you can interactively choose. For example, it can 260 discover if a dependency uses semantic versions and help you choose the version 261 ranges to use. 262 263 ### glide get [package name] 264 265 You can download one or more packages to your `vendor` directory and have it added to your 266 `glide.yaml` file with `glide get`. 267 268 ``` 269 $ glide get github.com/Masterminds/cookoo 270 ``` 271 272 When `glide get` is used it will introspect the listed package to resolve its 273 dependencies including using Godep, GPM, Gom, and GB config files. 274 275 ### glide update (aliased to up) 276 277 Download or update all of the libraries listed in the `glide.yaml` file and put 278 them in the `vendor` directory. It will also recursively walk through the 279 dependency packages to fetch anything that's needed and read in any configuration. 280 281 ``` 282 $ glide up 283 ``` 284 285 This will recurse over the packages looking for other projects managed by Glide, 286 Godep, gb, gom, and GPM. When one is found those packages will be installed as needed. 287 288 A `glide.lock` file will be created or updated with the dependencies pinned to 289 specific versions. For example, if in the `glide.yaml` file a version was 290 specified as a range (e.g., `^1.2.3`) it will be set to a specific commit id in 291 the `glide.lock` file. That allows for reproducible installs (see `glide install`). 292 293 To remove any nested `vendor/` directories from fetched packages see the `-v` flag. 294 295 ### glide install 296 297 When you want to install the specific versions from the `glide.lock` file use 298 `glide install`. 299 300 ``` 301 $ glide install 302 ``` 303 304 This will read the `glide.lock` file and install the commit id specific versions 305 there. 306 307 When the `glide.lock` file doesn't tie to the `glide.yaml` file, such as there 308 being a change, it will provide a warning. Running `glide up` will recreate the 309 `glide.lock` file when updating the dependency tree. 310 311 If no `glide.lock` file is present `glide install` will perform an `update` and 312 generate a lock file. 313 314 To remove any nested `vendor/` directories from fetched packages see the `-v` flag. 315 316 ## glide novendor (aliased to nv) 317 318 When you run commands like `go test ./...` it will iterate over all the 319 subdirectories including the `vendor` directory. When you are testing your 320 application you may want to test your application files without running all the 321 tests of your dependencies and their dependencies. This is where the `novendor` 322 command comes in. It lists all of the directories except `vendor`. 323 324 $ go test $(glide novendor) 325 326 This will run `go test` over all directories of your project except the 327 `vendor` directory. 328 329 ## glide name 330 331 When you're scripting with Glide there are occasions where you need to know 332 the name of the package you're working on. `glide name` returns the name of the 333 package listed in the `glide.yaml` file. 334 335 ### glide tree 336 337 Glide includes a few commands that inspect code and give you details 338 about what is imported. `glide tree` is one such command. Running it 339 gives data like this: 340 341 ``` 342 $ glide tree 343 github.com/Masterminds/glide 344 github.com/Masterminds/cookoo (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo) 345 github.com/Masterminds/cookoo/io (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo/io) 346 github.com/Masterminds/glide/cmd (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/cmd) 347 github.com/Masterminds/cookoo (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo) 348 github.com/Masterminds/cookoo/io (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo/io) 349 github.com/Masterminds/glide/gb (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/gb) 350 github.com/Masterminds/glide/util (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/util) 351 github.com/Masterminds/vcs (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs) 352 github.com/Masterminds/glide/yaml (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/yaml) 353 github.com/Masterminds/glide/util (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/util) 354 github.com/Masterminds/vcs (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs) 355 github.com/Masterminds/vcs (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs) 356 gopkg.in/yaml.v2 (/Users/mfarina/Code/go/src/gopkg.in/yaml.v2) 357 github.com/Masterminds/semver (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/semver) 358 github.com/Masterminds/vcs (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs) 359 github.com/codegangsta/cli (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/codegangsta/cli) 360 github.com/codegangsta/cli (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/codegangsta/cli) 361 github.com/Masterminds/cookoo (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo) 362 github.com/Masterminds/cookoo/io (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo/io) 363 github.com/Masterminds/glide/gb (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/gb) 364 github.com/Masterminds/glide/util (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/util) 365 github.com/Masterminds/vcs (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs) 366 github.com/Masterminds/glide/yaml (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/yaml) 367 github.com/Masterminds/glide/util (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/util) 368 github.com/Masterminds/vcs (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs) 369 github.com/Masterminds/vcs (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs) 370 gopkg.in/yaml.v2 (/Users/mfarina/Code/go/src/gopkg.in/yaml.v2) 371 github.com/Masterminds/semver (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/semver) 372 github.com/Masterminds/vcs (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs) 373 github.com/codegangsta/cli (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/codegangsta/cli) 374 ``` 375 376 This shows a tree of imports, excluding core libraries. Because 377 vendoring makes it possible for the same package to live in multiple 378 places, `glide tree` also prints the location of the package being 379 imported. 380 381 _This command is deprecated and will be removed in the near future._ 382 383 ### glide list 384 385 Glide's `list` command shows an alphabetized list of all the packages 386 that a project imports. 387 388 ``` 389 $ glide list 390 INSTALLED packages: 391 vendor/github.com/Masterminds/cookoo 392 vendor/github.com/Masterminds/cookoo/fmt 393 vendor/github.com/Masterminds/cookoo/io 394 vendor/github.com/Masterminds/cookoo/web 395 vendor/github.com/Masterminds/semver 396 vendor/github.com/Masterminds/vcs 397 vendor/github.com/codegangsta/cli 398 vendor/gopkg.in/yaml.v2 399 ``` 400 401 ### glide help 402 403 Print the glide help. 404 405 ``` 406 $ glide help 407 ``` 408 409 ### glide --version 410 411 Print the version and exit. 412 413 ``` 414 $ glide --version 415 glide version 0.12.0 416 ``` 417 418 ### glide.yaml 419 420 For full details on the `glide.yaml` files see [the documentation](https://glide.sh/docs/glide.yaml). 421 422 The `glide.yaml` file does two critical things: 423 424 1. It names the current package 425 2. It declares external dependencies 426 427 A brief `glide.yaml` file looks like this: 428 429 ```yaml 430 package: github.com/Masterminds/glide 431 import: 432 - package: github.com/Masterminds/semver 433 - package: github.com/Masterminds/cookoo 434 version: ^1.2.0 435 repo: git@github.com:Masterminds/cookoo.git 436 ``` 437 438 The above tells `glide` that... 439 440 1. This package is named `github.com/Masterminds/glide` 441 2. That this package depends on two libraries. 442 443 The first library exemplifies a minimal package import. It merely gives 444 the fully qualified import path. 445 446 When Glide reads the definition for the second library, it will get the repo 447 from the source in `repo`, checkout the latest version between 1.2.0 and 2.0.0, 448 and put it in `github.com/Masterminds/cookoo` in the `vendor` directory. (Note 449 that `package` and `repo` can be completely different) 450 451 **TIP:** The version is either VCS dependent and can be anything that can be checked 452 out or a semantic version constraint that can be parsed by the [`github.com/ 453 Masterminds/semver`](https://github.com/Masterminds/semver) package. 454 For example, with Git this can be a branch, tag, or hash. This varies and 455 depends on what's supported in the VCS. 456 457 **TIP:** In general, you are advised to use the *base package name* for 458 importing a package, not a subpackage name. For example, use 459 `github.com/kylelemons/go-gypsy` and not 460 `github.com/kylelemons/go-gypsy/yaml`. 461 462 ## Supported Version Control Systems 463 464 The Git, SVN, Mercurial (Hg), and Bzr source control systems are supported. This 465 happens through the [vcs package](https://github.com/masterminds/vcs). 466 467 ## Frequently Asked Questions (F.A.Q.) 468 469 #### Q: Why does Glide have the concept of sub-packages when Go doesn't? 470 471 In Go every directory is a package. This works well when you have one repo 472 containing all of your packages. When you have different packages in different 473 VCS locations things become a bit more complicated. A project containing a 474 collection of packages should be handled with the same information including 475 the version. By grouping packages this way we are able to manage the related 476 information. 477 478 #### Q: bzr (or hg) is not working the way I expected. Why? 479 480 These are works in progress, and may need some additional tuning. Please 481 take a look at the [vcs package](https://github.com/masterminds/vcs). If you 482 see a better way to handle it please let us know. 483 484 #### Q: Should I check `vendor/` into version control? 485 486 That's up to you. It's not necessary, but it may also cause you extra 487 work and lots of extra space in your VCS. There may also be unforeseen errors 488 ([see an example](https://github.com/mattfarina/golang-broken-vendor)). 489 490 #### Q: How do I import settings from GPM, Godep, gom or gb? 491 492 There are two parts to importing. 493 494 1. If a package you import has configuration for GPM, Godep, gom or gb Glide will 495 recursively install the dependencies automatically. 496 2. If you would like to import configuration from GPM, Godep, gom or gb to Glide see 497 the `glide import` command. For example, you can run `glide import godep` for 498 Glide to detect the projects Godep configuration and generate a `glide.yaml` 499 file for you. 500 501 Each of these will merge your existing `glide.yaml` file with the 502 dependencies it finds for those managers, and then emit the file as 503 output. **It will not overwrite your glide.yaml file.** 504 505 You can write it to file like this: 506 507 ``` 508 $ glide import godep -f glide.yaml 509 ``` 510 511 #### Q: Can Glide fetch a package based on OS or Arch? 512 513 A: Yes. Using the `os` and `arch` fields on a `package`, you can specify 514 which OSes and architectures the package should be fetched for. For 515 example, the following package will only be fetched for 64-bit 516 Darwin/OSX systems: 517 518 ```yaml 519 - package: some/package 520 os: 521 - darwin 522 arch: 523 - amd64 524 ``` 525 526 The package will not be fetched for other architectures or OSes. 527 528 ## LICENSE 529 530 This package is made available under an MIT-style license. See 531 LICENSE.txt. 532 533 ## Thanks! 534 535 We owe a huge debt of gratitude to the [GPM and 536 GVP](https://github.com/pote/gpm) projects, which 537 inspired many of the features of this package. If `glide` isn't the 538 right Go project manager for you, check out those. 539 540 The Composer (PHP), npm (JavaScript), and Bundler (Ruby) projects all 541 inspired various aspects of this tool, as well. 542 543 ## The Name 544 545 Aside from being catchy, "glide" is a contraction of "Go Elide". The 546 idea is to compress the tasks that normally take us lots of time into a 547 just a few seconds.