apiversion
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package apiversion provides an API version type that can be used to validatecompatibility between two API versions.
NOTE: API VERSIONS ARE NOT SEMANTIC VERSIONS.
API versions are represented as major.minor where major and minor are bothpositive integers.
API versions are not directly tied to a specific release of the software.Instead, they are used to represent the capabilities of the server. Forexample, a server that supports API version 1.2 should be able to handlerequests from clients that support API version 1.0, 1.1, or 1.2.However, a server that supports API version 2.0 is not required to handlerequests from clients that support API version 1.x.Clients may need to negotiate with the server to determine the highestsupported API version.
When making a change to the API, use the following rules to determine thenext API version:
- If the change is backward-compatible, increment the minor version.Examples of backward-compatible changes include adding new fields toa response or adding new endpoints.
- If the change is not backward-compatible, increment the major version.Examples of non-backward-compatible changes include removing or renamingfields.
Index¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
Types¶
typeAPIVersion¶
type APIVersion struct {// contains filtered or unexported fields}
funcNew¶
func New(maj, minorint) *APIVersion
New returns an *APIVersion with the given major.minor andadditional supported major versions.
func (*APIVersion)String¶
func (v *APIVersion) String()string
func (*APIVersion)Validate¶
func (v *APIVersion) Validate(versionstring)error
Validate validates the given version against the given constraints:A given major.minor version is valid iff:
- The requested major version is contained within v.supportedMajors
- If the requested major version is the 'current major', thenthe requested minor version must be less than or equal to the supportedminor version.
For example, given majors {1, 2} and minor 2, then:- 0.x is not supported,- 1.x is supported,- 2.0, 2.1, and 2.2 are supported,- 2.3+ is not supported.
func (*APIVersion)WithBackwardCompat¶
func (v *APIVersion) WithBackwardCompat(majs ...int) *APIVersion