{"id":28386174,"url":"https://github.com/bitnami/go-version","last_synced_at":"2025-08-18T20:35:44.327Z","repository":{"id":209803967,"uuid":"724981732","full_name":"bitnami/go-version","owner":"bitnami","description":"A Go library for parsing and verifying Bitnami versions and version constraints.","archived":false,"fork":false,"pushed_at":"2025-05-05T15:46:28.000Z","size":52,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-06-26T13:47:48.492Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitnami.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-11-29T07:32:25.000Z","updated_at":"2025-06-07T15:10:25.000Z","dependencies_parsed_at":"2024-03-15T10:39:24.614Z","dependency_job_id":"cbf5ab9a-af46-421d-b067-11577ea421aa","html_url":"https://github.com/bitnami/go-version","commit_stats":null,"previous_names":["bitnami/go-version"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bitnami/go-version","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitnami%2Fgo-version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitnami%2Fgo-version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitnami%2Fgo-version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitnami%2Fgo-version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitnami","download_url":"https://codeload.github.com/bitnami/go-version/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitnami%2Fgo-version/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271056802,"owners_count":24691824,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-30T13:11:21.325Z","updated_at":"2025-08-18T20:35:44.308Z","avatar_url":"https://github.com/bitnami.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/bitnami/go-version)](https://goreportcard.com/report/github.com/bitnami/go-version)\n[![CI](https://github.com/bitnami/go-version/actions/workflows/go.yml/badge.svg)](https://github.com/bitnami/go-version/actions/workflows/go.yml)\n\n# go-version\n\ngo-version is a library for parsing Bitnami package versions and version constraints and verifying versions against a set of constraints.\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n- [Usage](#usage)\n  - [Version parsing and comparison](#version-parsing-and-comparison)\n  - [Sorting](#sorting)\n  - [Version constraints](#version-constraints)\n    - [Version revision](#version-revision)\n    - [Missing major/minor/patch versions](#missing-majorminorpatch-versions)\n- [License](#license)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Usage\n\nVersions used with the `version` package must follow [Semantic Versioning](https://semver.org/) with small adjustments: **pre-release versions are considered revisions** and, therefore, the bigger the revision number, the newer the version.\n\n### Version parsing and comparison\n\nWhen two versions are compared using functions such as Compare, LessThan, and others, it will follow the specification and always include revisions within the comparison.\nIt will provide an answer that is valid with the comparison section of [the spec](https://semver.org/#spec-item-11).\n\n```go\nv1, _ := version.Parse(\"1.2.0\")\nv2, _ := version.Parse(\"1.2.1\")\n\n// Comparison example. There is also GreaterThan, Equal, and just\n// a simple Compare that returns an int allowing easy \u003e=, \u003c=, etc.\nif v1.LessThan(v2) {\n    fmt.Printf(\"%s is less than %s\", v1, v2)\n}\n```\n\n### Sorting\n\nCollections of versions can be sorted using the `sort.Sort` function from the standard library.\n\n```go\nversionsRaw := []string{\"1.1.0\", \"0.7.1\", \"1.4.0\", \"1.4.0-alpha\", \"1.4.1-beta\", \"1.4.0-alpha.2+20130313144700\"}\nversions := make(version.Collection, len(versionsRaw))\nfor i, raw := range versionsRaw {\n    v, _ := version.Parse(raw)\n    versions[i] = v\n}\n\n// After this, the versions are properly sorted\nsort.Sort(versions)\n```\n\n### Version constraints\n\nComma-separated version constraints are considered an `AND`. For example, `\u003e= 1.2.3, \u003c 2.0.0` means the version needs to be greater than or equal to `1.2` and less than `3.0.0`.\nIn addition, they can be separated by `|| (OR)`. For example, `\u003e= 1.2.3, \u003c 2.0.0 || \u003e 4.0.0` means the version needs to be greater than or equal to `1.2` and less than `3.0.0`, or greater than `4.0.0`.\n\n```go\nv, _ := version.Parse(\"2.1.0\")\nc, _ := version.NewConstraints(\"\u003e= 1.0, \u003c 1.4 || \u003e 2.0\")\n\nif c.Check(v) {\n    fmt.Printf(\"%s satisfies constraints '%s'\", v, c)\n}\n```\n\nSupported operators:\n\n- `=` : you accept that exact version\n- `!=` : not equal\n- `\u003e` : you accept any version higher than the one you specify\n- `\u003e=` : you accept any version equal to or higher than the one you specify\n- `\u003c` : you accept any version lower to the one you specify\n- `\u003c=` : you accept any version equal or lower to the one you specify\n- `^` : it will only do updates that do not change the leftmost non-zero number.\n  - e.g. `^1.2.3` := `\u003e=1.2.3, \u003c2.0.0`\n- `~` : allows patch-level changes if a minor version is specified on the comparator. Allows minor-level changes if not.\n  - e.g. `~1.2.3` := `\u003e=1.2.3, \u003c1.3.0`\n\n#### Version revision\n\nA revision may be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. Revision has a greater precedence than the associated normal version (e.g. `1.2.3-1 \u003e 1.2.3`).\n\n```go\nv, _ := version.Parse(\"2.0.0\")\nc, _ := version.NewConstraints(\"\u003e2.0.0-2\")\n\nc.Check(v) // false\n```\n\nComparisons include revisions even with no revisions constraint:\n\n```go\nv, _ := version.Parse(\"2.0.0-1\")\nc, _ := version.NewConstraints(\"\u003e2.0.0\")\n\nc.Check(v) // true\n```\n\n#### Missing major/minor/patch versions\n\nIf some of the major/minor/patch versions are not specified, it is treated as `*` by default. In short, `3.1.3` satisfies `= 3` because `= 3` is converted to `= 3.*.*`.\n\n```go\nv, _ := version.Parse(\"2.3.4\")\nc, _ := version.NewConstraints(\"=2\")\n\nc.Check(v) // true\n```\n\nThen, `2.2.3` doesn't satisfy `\u003e 2` as `\u003e 2` is treated as `\u003e 2.*.*` = `\u003e= 3.0.0`\n\n```go\nv, _ := version.Parse(\"2.2.3\")\nc, _ := version.NewConstraints(\"\u003e2\")\n\nc.Check(v) // false\n```\n\n`3.3.9` satisifies `= 3.3`, and `5.1.2` doesn't satisfy `\u003e 5.1` likewise.\n\nIf you want to treat them as 0, you can pass `version.WithZeroPadding(true)` as an argument of `version.NewConstraints`\n\n```go\nv, _ := version.Parse(\"2.3.4\")\nc, _ := version.NewConstraints(\"= 2\", version.WithZeroPadding(true))\n\nc.Check(v) // false\n```\n\n## License\n\nCopyright \u0026copy; 2025 Broadcom. The term \"Broadcom\" refers to Broadcom Inc. and/or its subsidiaries.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License.\n\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitnami%2Fgo-version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitnami%2Fgo-version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitnami%2Fgo-version/lists"}