docker / cli

The Docker CLI
Apache License 2.0
4.74k stars 1.88k forks source link

cli/command/image: add go:build tag to prevent downgrading go version #5162

Closed thaJeztah closed 2 weeks ago

thaJeztah commented 2 weeks ago

Before this:

make shell
make -C ./internal/gocompat/
...

GO111MODULE=on go test -v
# github.com/docker/cli/cli/command/image
../../cli/command/image/push.go:177:62: predeclared any requires go1.18 or later (-lang was set to go1.16; check go.mod)
FAIL    gocompat [build failed]
make: *** [Makefile:3: verify] Error 1
make: Leaving directory '/go/src/github.com/docker/cli/internal/gocompat'

After this patch:

make shell
make -C ./internal/gocompat/
...

GO111MODULE=on go test -v
=== RUN   TestModuleCompatibllity
    main_test.go:133: all packages have the correct go version specified through //go:build
--- PASS: TestModuleCompatibllity (0.00s)
PASS
ok      gocompat    0.007s
make: Leaving directory '/go/src/github.com/docker/cli/internal/gocompat'

- Description for the changelog

Fix a compile error when using the CLI code as a go module

- A picture of a cute animal (not mandatory but encouraged)

codecov-commenter commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 61.75%. Comparing base (6904185) to head (1fd8e24).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #5162 +/- ## ========================================== - Coverage 61.76% 61.75% -0.01% ========================================== Files 297 297 Lines 20768 20768 ========================================== - Hits 12828 12826 -2 - Misses 7024 7025 +1 - Partials 916 917 +1 ```