{"id":13461342,"url":"https://github.com/hashicorp/go-version","last_synced_at":"2025-05-13T20:03:17.065Z","repository":{"id":15395808,"uuid":"18127628","full_name":"hashicorp/go-version","owner":"hashicorp","description":"A Go (golang) library for parsing and verifying versions and version constraints.","archived":false,"fork":false,"pushed_at":"2025-05-01T06:06:38.000Z","size":117,"stargazers_count":1682,"open_issues_count":39,"forks_count":152,"subscribers_count":284,"default_branch":"main","last_synced_at":"2025-05-06T19:51:58.853Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/hashicorp/go-version","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hashicorp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-03-26T05:16:55.000Z","updated_at":"2025-05-06T11:45:52.000Z","dependencies_parsed_at":"2024-05-21T13:36:57.253Z","dependency_job_id":"1c28f8ef-0a7a-4f98-93da-0e6f1b42522f","html_url":"https://github.com/hashicorp/go-version","commit_stats":{"total_commits":102,"total_committers":38,"mean_commits":"2.6842105263157894","dds":0.696078431372549,"last_synced_commit":"fcaa53267960208632e9308c93aa89535526a018"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashicorp%2Fgo-version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashicorp%2Fgo-version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashicorp%2Fgo-version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashicorp%2Fgo-version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hashicorp","download_url":"https://codeload.github.com/hashicorp/go-version/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254020473,"owners_count":22000750,"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-07-31T11:00:35.189Z","updated_at":"2025-05-13T20:03:17.039Z","avatar_url":"https://github.com/hashicorp.png","language":"Go","funding_links":[],"categories":["Misc","Go","开源类库","Open source library"],"sub_categories":["未归类","Not Categorized"],"readme":"# Versioning Library for Go\n![Build Status](https://github.com/hashicorp/go-version/actions/workflows/go-tests.yml/badge.svg)\n[![GoDoc](https://godoc.org/github.com/hashicorp/go-version?status.svg)](https://godoc.org/github.com/hashicorp/go-version)\n\ngo-version is a library for parsing versions and version constraints,\nand verifying versions against a set of constraints. go-version\ncan sort a collection of versions properly, handles prerelease/beta\nversions, can increment versions, etc.\n\nVersions used with go-version must follow [SemVer](http://semver.org/).\n\n## Installation and Usage\n\nPackage documentation can be found on\n[GoDoc](http://godoc.org/github.com/hashicorp/go-version).\n\nInstallation can be done with a normal `go get`:\n\n```\n$ go get github.com/hashicorp/go-version\n```\n\n#### Version Parsing and Comparison\n\n```go\nv1, err := version.NewVersion(\"1.2\")\nv2, err := version.NewVersion(\"1.5+metadata\")\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#### Version Constraints\n\n```go\nv1, err := version.NewVersion(\"1.2\")\n\n// Constraints example.\nconstraints, err := version.NewConstraint(\"\u003e= 1.0, \u003c 1.4\")\nif constraints.Check(v1) {\n\tfmt.Printf(\"%s satisfies constraints %s\", v1, constraints)\n}\n```\n\n#### Version Sorting\n\n```go\nversionsRaw := []string{\"1.1\", \"0.7.1\", \"1.4-beta\", \"1.4\", \"2\"}\nversions := make([]*version.Version, len(versionsRaw))\nfor i, raw := range versionsRaw {\n    v, _ := version.NewVersion(raw)\n    versions[i] = v\n}\n\n// After this, the versions are properly sorted\nsort.Sort(version.Collection(versions))\n```\n\n## Issues and Contributing\n\nIf you find an issue with this library, please report an issue. If you'd\nlike, we welcome any contributions. Fork this library and submit a pull\nrequest.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashicorp%2Fgo-version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhashicorp%2Fgo-version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashicorp%2Fgo-version/lists"}