Glide supports a simple plugin system similar to Git.
Some plugins exist today for Glide including:
- glide-vc - The vendor cleaner allows you to strip files not needed for building your application from the
- glide-brew - Convert Go deps managed by glide to Homebrew resources to help you make brew formulas for you Go programs.
- glide-hash - Generates a hash of the
glide.yamlfile compatible with Glides internal hash.
- glide-cleanup - Removing unused packages from the
- glide-pin - Take all dependencies from the
glide.lockand pin them explicitly in the
Note, to add plugins to this list please create a pull request.
How Plugins Work
When Glide encounters a subcommand that it does not know, it will try to delegate it to another executable according to the following rules.
$ glide install # We know this command, so we execute it $ glide foo # We don't know this command, so we look for a suitable # plugin.
In the example above, when glide receives the command
foo, which it does not know, it will do the following:
- Transform the name from
- Look on the system
glide-foo. If it finds a program by that name, execute it...
- Or else, look at the current project's root for
glide-foo. (That is, look in the same directory as
glide.yaml). If found, execute it.
- If no suitable command is found, exit with an error.
Writing a Glide Plugin
A Glide plugin can be written in any language you wish, provided that it can be executed from the command line as a subprocess of Glide. The example included with Glide is a simple Bash script. We could just as easily write Go, Python, Perl, or even Java code (with a wrapper) to execute.
A Glide plugin must be in one of two locations:
- Somewhere on the PATH
- In the same directory as
It is recommended that system-wide Glide plugins go in
$GOPATH/bin while project-specific plugins go in the same directory as
Arguments and Flags
Say Glide is executed like this:
$ glide foo -name=Matt myfile.txt
Glide will interpret this as a request to execute
glide-foo with the arguments
-name=Matt myfile.txt. It will not attempt to interpret those arguments or modify them in any way.
Hypothetically, if Glide had a
-x flag of its own, you could call this:
$ glide -x foo -name=Matt myfile.txt
In this case, glide would interpret and swollow the -x and pass the rest on to
glide-foo as in the example above.
#!/bin/bash echo "Hello"