The Moby Project - a collaborative project for the container ecosystem to assemble container-based systems
Find a file
Sebastiaan van Stijn 2cf230951f
add //go:build directives to prevent downgrading to go1.16 language
This repository is not yet a module (i.e., does not have a `go.mod`). This
is not problematic when building the code in GOPATH or "vendor" mode, but
when using the code as a module-dependency (in module-mode), different semantics
are applied since Go1.21, which switches Go _language versions_ on a per-module,
per-package, or even per-file base.

A condensed summary of that logic [is as follows][1]:

- For modules that have a go.mod containing a go version directive; that
  version is considered a minimum _required_ version (starting with the
  go1.19.13 and go1.20.8 patch releases: before those, it was only a
  recommendation).
- For dependencies that don't have a go.mod (not a module), go language
  version go1.16 is assumed.
- Likewise, for modules that have a go.mod, but the file does not have a
  go version directive, go language version go1.16 is assumed.
- If a go.work file is present, but does not have a go version directive,
  language version go1.17 is assumed.

When switching language versions, Go _downgrades_ the language version,
which means that language features (such as generics, and `any`) are not
available, and compilation fails. For example:

    # github.com/docker/cli/cli/context/store
    /go/pkg/mod/github.com/docker/cli@v25.0.0-beta.2+incompatible/cli/context/store/storeconfig.go:6:24: predeclared any requires go1.18 or later (-lang was set to go1.16; check go.mod)
    /go/pkg/mod/github.com/docker/cli@v25.0.0-beta.2+incompatible/cli/context/store/store.go:74:12: predeclared any requires go1.18 or later (-lang was set to go1.16; check go.mod)

Note that these fallbacks are per-module, per-package, and can even be
per-file, so _(indirect) dependencies_ can still use modern language
features, as long as their respective go.mod has a version specified.

Unfortunately, these failures do not occur when building locally (using
vendor / GOPATH mode), but will affect consumers of the module.

Obviously, this situation is not ideal, and the ultimate solution is to
move to go modules (add a go.mod), but this comes with a non-insignificant
risk in other areas (due to our complex dependency tree).

We can revert to using go1.16 language features only, but this may be
limiting, and may still be problematic when (e.g.) matching signatures
of dependencies.

There is an escape hatch: adding a `//go:build` directive to files that
make use of go language features. From the [go toolchain docs][2]:

> The go line for each module sets the language version the compiler enforces
> when compiling packages in that module. The language version can be changed
> on a per-file basis by using a build constraint.
>
> For example, a module containing code that uses the Go 1.21 language version
> should have a `go.mod` file with a go line such as `go 1.21` or `go 1.21.3`.
> If a specific source file should be compiled only when using a newer Go
> toolchain, adding `//go:build go1.22` to that source file both ensures that
> only Go 1.22 and newer toolchains will compile the file and also changes
> the language version in that file to Go 1.22.

This patch adds `//go:build` directives to those files using recent additions
to the language. It's currently using go1.19 as version to match the version
in our "vendor.mod", but we can consider being more permissive ("any" requires
go1.18 or up), or more "optimistic" (force go1.21, which is the version we
currently use to build).

For completeness sake, note that any file _without_ a `//go:build` directive
will continue to use go1.16 language version when used as a module.

[1]: 58c28ba286/src/cmd/go/internal/gover/version.go (L9-L56)
[2]: https://go.dev/doc/toolchain

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-15 15:24:15 +01:00
.github update to go1.21.5 2023-12-05 23:27:58 +01:00
api add //go:build directives to prevent downgrading to go1.16 language 2023-12-15 15:24:15 +01:00
builder add //go:build directives to prevent downgrading to go1.16 language 2023-12-15 15:24:15 +01:00
cli frozen images: update to debian:bookworm-slim 2023-11-30 12:01:06 +01:00
client update to go.opentelemetry.io/otel/semconv/v1.21.0, remove "httpconv" uses 2023-12-12 12:27:37 +01:00
cmd update to go.opentelemetry.io/otel/semconv/v1.21.0, remove "httpconv" uses 2023-12-12 12:27:37 +01:00
container container: internalize InitAttachContext 2023-11-30 15:26:53 +01:00
contrib frozen images: update to debian:bookworm-slim 2023-11-30 12:01:06 +01:00
daemon add //go:build directives to prevent downgrading to go1.16 language 2023-12-15 15:24:15 +01:00
distribution distribution: Add Tags 2023-10-16 14:19:27 +02:00
dockerversion dockerversion: DockerUserAgent(): allow custom versions to be passed 2023-06-01 18:21:58 +02:00
docs Merge pull request #46939 from vvoland/api-deprecate-image-container 2023-12-14 20:54:59 +01:00
errdefs Plumb context through info endpoint 2023-11-10 20:09:25 +00:00
hack Merge pull request #46916 from thaJeztah/bump_docker_py 2023-12-11 12:02:23 +01:00
image replace some strings with OCI consts 2023-10-17 16:34:52 +02:00
integration integration/prune: Run in a separate daemon 2023-12-07 17:33:26 +01:00
integration-cli Merge pull request #46847 from thaJeztah/uncontainerise_TestDaemonNoSpaceLeftOnDeviceError 2023-12-07 20:02:29 +01:00
internal hack: Load special images on demand 2023-12-06 17:16:37 +01:00
layer migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
libcontainerd Merge pull request #46227 from thaJeztah/supervisor_ignore_errs 2023-11-22 08:40:45 +01:00
libnetwork add //go:build directives to prevent downgrading to go1.16 language 2023-12-15 15:24:15 +01:00
oci Merge pull request from GHSA-jq35-85cj-fj4p 2023-10-25 23:57:51 +02:00
opts opts: ValidateIPAddress: improve error, godoc, and tests 2023-11-11 15:31:19 +01:00
pkg Plumb context through info endpoint 2023-11-10 20:09:25 +00:00
plugin api/types: move Plugin-types to api/types/backend 2023-12-06 02:16:02 +01:00
profiles seccomp: block io_uring_* syscalls in default profile 2023-11-02 19:05:47 +01:00
project project: document supported containerd versions 2023-11-06 13:43:18 -05:00
quota quota: increase sparse test-image to 300MB 2023-11-27 16:08:08 +01:00
reference migrate to new github.com/distribution/reference module 2023-09-05 12:09:26 +02:00
registry Merge pull request #46594 from regisb/36598-regisb/registry-mirror-path 2023-10-12 20:37:52 +02:00
reports Fix typos 2018-05-16 09:15:43 +08:00
restartmanager restartmanager: rename max/min as it collides with go1.21 builtin 2023-08-26 19:37:19 +02:00
runconfig Merge pull request #46447 from akerouanton/api-predefined-networks 2023-11-24 12:26:48 +01:00
testutil add //go:build directives to prevent downgrading to go1.16 language 2023-12-15 15:24:15 +01:00
vendor logger: remove logentries driver 2023-12-12 22:51:23 +01:00
volume Don't allow port in CIFS URL 2023-12-04 10:08:09 +00:00
.dockerignore ignorefiles: cleanup 2022-11-21 18:43:42 -07:00
.gitattributes chore: fix linguist for Dockerfile 2022-04-27 06:38:41 +02:00
.gitignore hack: introduce validate/no-module 2022-12-12 18:39:06 -07:00
.golangci.yml Move the golangci-lint configuration file to the root dir 2023-10-30 13:48:58 +01:00
.mailmap update authors and mailmap 2023-11-13 22:12:58 +01:00
AUTHORS update authors and mailmap 2023-11-13 22:12:58 +01:00
codecov.yml codecov: disable "patch" status 2022-06-07 17:24:46 +02:00
CONTRIBUTING.md CONTRIBUTING.md: update links to golang docs and blog 2023-08-25 12:43:31 +02:00
docker-bake.hcl Dockerfile: remove APT_MIRROR build-arg 2023-12-04 13:52:58 +01:00
Dockerfile update containerd binary to 1.7.11 2023-12-09 01:26:44 +01:00
Dockerfile.simple update to go1.21.5 2023-12-05 23:27:58 +01:00
Dockerfile.windows update containerd binary to 1.7.11 2023-12-09 01:26:44 +01:00
Jenkinsfile remove s390x and ppc64ls pipelines 2023-08-14 16:54:44 +02:00
LICENSE Update LICENSE 2018-09-12 14:27:53 +01:00
MAINTAINERS Add dmcgowan as curator 2023-09-13 17:22:24 +02:00
Makefile Dockerfile: remove APT_MIRROR build-arg 2023-12-04 13:52:58 +01:00
NOTICE switch kr/pty to creack/pty v1.1.7 2019-07-29 16:59:08 -07:00
README.md Fix grammar in README.md 2022-11-10 19:49:41 +00:00
ROADMAP.md Fix some typos in ROADMAP.md 2019-01-25 14:27:13 +08:00
SECURITY.md Update SECURITY.md to have an option to keep name anonymous if requested. 2019-06-18 16:37:16 +00:00
TESTING.md TESTING.md: note that integration-cli is deprecated 2020-12-18 07:51:46 +01:00
vendor.mod logger: remove logentries driver 2023-12-12 22:51:23 +01:00
vendor.sum logger: remove logentries driver 2023-12-12 22:51:23 +01:00
VENDORING.md fix the bare url and the Summary of http://semver.org 2017-01-17 16:20:11 +08:00

The Moby Project

Moby Project logo

Moby is an open-source project created by Docker to enable and accelerate software containerization.

It provides a "Lego set" of toolkit components, the framework for assembling them into custom container-based systems, and a place for all container enthusiasts and professionals to experiment and exchange ideas. Components include container build tools, a container registry, orchestration tools, a runtime and more, and these can be used as building blocks in conjunction with other tools and projects.

Principles

Moby is an open project guided by strong principles, aiming to be modular, flexible and without too strong an opinion on user experience. It is open to the community to help set its direction.

  • Modular: the project includes lots of components that have well-defined functions and APIs that work together.
  • Batteries included but swappable: Moby includes enough components to build fully featured container systems, but its modular architecture ensures that most of the components can be swapped by different implementations.
  • Usable security: Moby provides secure defaults without compromising usability.
  • Developer focused: The APIs are intended to be functional and useful to build powerful tools. They are not necessarily intended as end user tools but as components aimed at developers. Documentation and UX is aimed at developers not end users.

Audience

The Moby Project is intended for engineers, integrators and enthusiasts looking to modify, hack, fix, experiment, invent and build systems based on containers. It is not for people looking for a commercially supported system, but for people who want to work and learn with open source code.

Relationship with Docker

The components and tools in the Moby Project are initially the open source components that Docker and the community have built for the Docker Project. New projects can be added if they fit with the community goals. Docker is committed to using Moby as the upstream for the Docker Product. However, other projects are also encouraged to use Moby as an upstream, and to reuse the components in diverse ways, and all these uses will be treated in the same way. External maintainers and contributors are welcomed.

The Moby project is not intended as a location for support or feature requests for Docker products, but as a place for contributors to work on open source code, fix bugs, and make the code more useful. The releases are supported by the maintainers, community and users, on a best efforts basis only, and are not intended for customers who want enterprise or commercial support; Docker EE is the appropriate product for these use cases.


Legal

Brought to you courtesy of our legal counsel. For more context, please see the NOTICE document in this repo.

Use and transfer of Moby may be subject to certain restrictions by the United States and other governments.

It is your responsibility to ensure that your use and/or transfer does not violate applicable laws.

For more information, please see https://www.bis.doc.gov

Licensing

Moby is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.