`make run` errors during fmt or vet stage

An example error

When you run make run it will first run go fmt and go vet. If either of these commands find issues you will see an error like this:

root@kubernetes-vm:~/demo# make run
test -s /root/demo/bin/controller-gen || GOBIN=/root/demo/bin go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.2
/root/demo/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
/root/demo/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go fmt ./...
go vet ./...
# my.domain/controllers
controllers/website_controller.go:78:6: undefined: errors
controllers/website_controller.go:89:6: undefined: errors
# my.domain/controllers
vet: controllers/website_controller.go:78:6: undeclared name: errors
make: *** [Makefile:55: vet] Error 2

Fixing the issue

go fmt should be run on save in the Code editor. If you chose to edit the files in a different way (e.g. via vim) it would be easiest to open the file in the Code editor tab, make a small white space change (e.g. enter an extra new line somewhere) and then save the file using ctrl+s (or cmd+s on a mac).

If you want to continue using another editor, make sure to run the appropriate fmt commands prior to running make run.

Last updated