Documentation
¶
Overview ¶
Package debgover provides functions for converting between Go module version strings and Debian package version strings.
The behavior of this package is intended to conform with the Debian Go team's version number documentation and common practices.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DebianToGo ¶
DebianToGo converts the upstream part of a Debian version to a Go semver-compatible version. The conversion is lossy; the resulting version is only intended to be used to determine whether a particular version of a Go module has already been Debianized. If the Debian version represents a version control (e.g., Git) snapshot, the returned value is a Go pseudo-version.
Rough approach, which is subject to change:
Start processing the version as if it was a semver version string, except:
* Add a leading "v" prefix.
* If a "-" (hyphen) is encountered and it is a legal place to start a pre-release component, the "-" instead stops semver processing and that character to the end of the string are set aside for post processing.
* If a "~" (tilde) is encountered and it is a legal place to start a pre-release component and the following characters don't match a snapshot indicator (e.g., "~git20251028.abcdef0"), the "~" starts a pre-release component (the "~" is replaced with "-" in the output).
* If a "+" (plus) is encountered and it is a legal place to start a build metadata component and the following characters match a snapshot indicator (e.g., "+git20251028.abcdef0"), the "+" instead stops semver processing and that character to the end of the string are set aside for post-processing.
* If a character is encountered that is not legal for semver, semver processing stops and that character to the end of the string are set aside for post-processing.
If the processed part is not a valid semver string, an error is returned.
The semver is canonicalized, with any build metadata component preserved.
If the unprocessed remainder starts with a snapshot indicator (e.g., "~git20251028.abcdef0"), the date, revision, and base version are combined to construct a Go pseudo-version.
The remainder is discarded.
func GoToDebian ¶
func GoToDebian(mod module.Version) (debversion.Version, error)
GoToDebian converts a Go version string to a Debian upstream version. Due to differences between the Debian and semver sorting algorithms, it is technically possible but unlikely for two versions to swap order after conversion. For a Go pseudo-version, the version control system is assumed to be Git.
Types ¶
This section is empty.