Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
85 lines (59 sloc) 2.17 KB

Contributor Guide

This guide is intended for people who want to start working on krew itself. If you intend to write a new plugin, see Developer Guide instead.

Setting up the environment

Krew is built with go 1.10, but newer versions will do as well. Most toolchains will expect that the krew repository is on the GOPATH. To set it up correctly, do

mkdir -p $(go env GOPATH)/src/
cd $(go env GOPATH)/src/
git clone .
git remote set-url origin --push no_push   # to avoid pushes

Code style

Krew adheres to standard golang code formatting conventions, and also expects imports sorted properly. To automatically format code appropriately, install goimports via

go get

and run:

goimports -w cmd pkg

In addition, a boilerplate license header is expected in all source files.

All new code should be covered by tests.

Running tests

To run tests locally, the easiest way to get started is with


This will run all unit tests and code quality tools. To run a single tool independently of the other code checks, have a look at the other scripts in hack/.

In addition, there are integration tests to cover high-level krew functionality. To run integration tests, you will need to build the krew binary beforehand:


Testing krew in a sandbox

After making changes to krew, you should also check that it behaves as expected. You can do this without messing up the krew installation on the host system by setting the KREW_ROOT environment variable. For example:

mkdir playground
KREW_ROOT="$PWD/playground" krew update

Any changes that krew is going to apply will then be applied in the playground/ folder, instead of the standard ~/.krew folder.

Testing in a docker sandbox

Alternatively, if the isolation provided by KREW_ROOT is not enough, there is also a script to run krew in a docker sandbox:

You can’t perform that action at this time.