{"id":13694566,"url":"https://github.com/mcuadros/go-version","last_synced_at":"2025-05-03T04:30:32.295Z","repository":{"id":8220567,"uuid":"9658206","full_name":"mcuadros/go-version","owner":"mcuadros","description":"Version normalizer and comparison library for go","archived":true,"fork":false,"pushed_at":"2019-08-30T08:33:32.000Z","size":49,"stargazers_count":138,"open_issues_count":1,"forks_count":28,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-25T06:02:46.291Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcuadros.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-24T21:37:50.000Z","updated_at":"2025-03-13T08:04:03.000Z","dependencies_parsed_at":"2022-09-17T05:02:09.461Z","dependency_job_id":null,"html_url":"https://github.com/mcuadros/go-version","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcuadros%2Fgo-version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcuadros%2Fgo-version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcuadros%2Fgo-version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcuadros%2Fgo-version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcuadros","download_url":"https://codeload.github.com/mcuadros/go-version/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252144275,"owners_count":21701379,"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","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":"2024-08-02T17:01:34.879Z","updated_at":"2025-05-03T04:30:31.987Z","avatar_url":"https://github.com/mcuadros.png","language":"Go","funding_links":[],"categories":["开源类库","Open source library"],"sub_categories":["未归类","Not Categorized"],"readme":"go-version [![Build Status](https://travis-ci.org/mcuadros/go-version.svg?branch=master)](https://travis-ci.org/mcuadros/go-version) [![GoDoc](https://godoc.org/github.com/mcuadros/go-version?status.svg)](http://godoc.org/github.com/mcuadros/go-version)\n==============================\n\nVersion normalizer and comparison library for go, heavy based on PHP version_compare function and Version comparsion libs from [Composer](https://github.com/composer/composer) PHP project\n\nInstallation\n------------\n\nThe recommended way to install go-version\n\n```\ngo get github.com/mcuadros/go-version\n```\n\nExamples\n--------\n\nHow import the package\n\n```go\nimport (\n    \"github.com/mcuadros/go-version\"\n)\n```\n\n`version.Normalize()`: Normalizes a version string to be able to perform comparisons on it\n\n```go\nversion.Normalize(\"10.4.13-b\")\n//Returns: 10.4.13.0-beta\n```\n\n\n`version.CompareSimple()`: Compares two normalizated version number strings\n\n```go\nversion.CompareSimple(\"1.2\", \"1.0.1\")\n//Returns: 1\n\nversion.CompareSimple(\"1.0rc1\", \"1.0\")\n//Returns: -1\n```\n\n\n`version.Compare()`: Compares two normalizated version number strings, for a particular relationship\n\n```go\nversion.Compare(\"1.0-dev\", \"1.0\", \"\u003c\")\n//Returns: true\n\nversion.Compare(\"1.0rc1\", \"1.0\", \"\u003e=\")\n//Returns: false\n\nversion.Compare(\"2.3.4\", \"v3.1.2\", \"\u003c\")\n//Returns: true\n```\n\n`version.ConstrainGroup.Match()`: Match a given version againts a group of constrains, read about constraint string format at [Composer documentation](http://getcomposer.org/doc/01-basic-usage.md#package-versions)  \n\n```go\nc := version.NewConstrainGroupFromString(\"\u003e2.0,\u003c=3.0\")\nc.Match(\"2.5.0beta\")\n//Returns: true\n\nc := version.NewConstrainGroupFromString(\"~1.2.3\")\nc.Match(\"1.2.3.5\")\n//Returns: true\n```\n\n`version.Sort()`: Sorts a string slice of version number strings using version.CompareSimple()\n\n```go\nversion.Sort([]string{\"1.10-dev\", \"1.0rc1\", \"1.0\", \"1.0-dev\"})\n//Returns []string{\"1.0-dev\", \"1.0rc1\", \"1.0\", \"1.10-dev\"}\n```\n\nLicense\n-------\n\nMIT, see [LICENSE](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcuadros%2Fgo-version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcuadros%2Fgo-version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcuadros%2Fgo-version/lists"}