Friday, 30 December 2022

Weirdness with Go

Whilst tinkering ( my fave word ) with a Go project,  I was trying to force a complete rebuild of the module, via go mod tidy.

Now I started by removing go.mod and go.sum : -

rm go.mod
rm go.sum

And, when I ran go mod tidy  I noticed that the command was: -

(a) failing
(b) looking at a whole slew of OTHER Go projects, including those outside of the directory within which I was running the command, namely : -

/root/go/src/github.com/docker/sbom-cli-plugin

Now, of course, note what I did previously i.e. rm go.mod 

THAT WAS MY DOWNFALL :-)

From this: -

Why does 'go mod tidy' record indirect and test dependencies in my 'go.mod'?

<snip>

go mod tidy updates your current go.mod to include the dependencies needed for tests in your module — if a test fails, we must know which dependencies were used in order to reproduce the failure.

</snip>

Guess what I didn't have ?

So, the key was to re-create go.mod via: -

go mod init

and then re-run the make command that had initially populated go.mod - which also ran go mod tidy and then ... everything is OK.

Phew !


No comments:

Note to self - use kubectl to query images in a pod or deployment

In both cases, we use JSON ... For a deployment, we can do this: - kubectl get deployment foobar --namespace snafu --output jsonpath="{...