Movatterモバイル変換


[0]ホーム

URL:


apiversion

package
v2.23.0Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2025 License:AGPL-3.0Imports:4Imported by:0

Details

Repository

github.com/coder/coder

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:

  1. 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.
  2. 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

funcParse

func Parse(versionstring) (majorint, minorint, errerror)

Parse parses a valid major.minor version string into (major, minor).Both major and minor must be valid integers separated by a period '.'.

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:

  1. The requested major version is contained within v.supportedMajors
  2. 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

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp