{"id":15861854,"url":"https://github.com/yakdriver/go-version","last_synced_at":"2025-04-01T20:34:21.951Z","repository":{"id":221245450,"uuid":"753771988","full_name":"YakDriver/go-version","owner":"YakDriver","description":"Compare versions with an inclusive policy for wonky versions.","archived":false,"fork":false,"pushed_at":"2024-02-07T02:33:46.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T13:18:35.853Z","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":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YakDriver.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-06T19:04:30.000Z","updated_at":"2024-02-26T12:57:00.000Z","dependencies_parsed_at":"2024-02-06T23:31:00.564Z","dependency_job_id":"7ceb833d-8ffc-4ba0-ad77-af98b0a17cfc","html_url":"https://github.com/YakDriver/go-version","commit_stats":null,"previous_names":["yakdriver/go-version"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YakDriver%2Fgo-version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YakDriver%2Fgo-version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YakDriver%2Fgo-version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YakDriver%2Fgo-version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YakDriver","download_url":"https://codeload.github.com/YakDriver/go-version/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246709931,"owners_count":20821297,"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-10-05T22:20:42.793Z","updated_at":"2025-04-01T20:34:21.908Z","avatar_url":"https://github.com/YakDriver.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-version\n\n**`go-version`** attempts to compare versions. It uses this precedence in comparing:\n\n1. The earliest time associated with a version (only when using `LessThanWithTime()`)\n2. Semantic-versioning parsing based on [go-version](https://github.com/hashicorp/go-version)\n3. If the version breaks semantic versioning rules, a smart comparison looking at the version as a version-like thing\n4. A plain string comparison\n\n_Version comparison will not return errors in any situation._\n\n`go-version` is optimized for the versions used by AWS RDS database engine versions. It will likely work with many other version-like situations.\n\n# Usage examples\n\n\n## `LessThan`\n\nIf you're just comparing version strings without associated times, such as the version create times, use `LessThan()`:\n\n[On Go Playground](https://go.dev/play/p/1lflUMIFPwT)\n\n```go\npackage main\n\nimport (\n    \"time\"\n\n    \"github.com/YakDriver/go-version\"\n)\n\nfunc main() {\n    // normal semantic-versioning versions\n    fmt.Printf(\"%t\\n\", version.LessThan(\"10.11.9\", \"10.11.10\")) // true\n    fmt.Printf(\"%t\\n\", version.LessThan(\"10.4\", \"10.4.27\")) // true\n    fmt.Printf(\"%t\\n\", version.LessThan(\"10.6.8\", \"11\")) // true\n    fmt.Printf(\"%t\\n\", version.LessThan(\"1.2rc2\", \"1.2\")) // true\n\n    // non-semantic-versioning versions\n    fmt.Printf(\"%t\\n\", version.LessThan(\"8.0.mysql_aurora.3.1.9\", \"8.0.mysql_aurora.3.1.10\")) // true\n    fmt.Printf(\"%t\\n\", version.LessThan(\"19.0.0.0.ru-2023-10.rur-2023-10.r9\", \"19.0.0.0.ru-2023-10.rur-2023-10.r10\")) // true \n    fmt.Printf(\"%t\\n\", version.LessThan(\"14.00.3281.5.v1\", \"14.00.3281.6.v1\")) // true   \n    fmt.Printf(\"%t\\n\", version.LessThan(\"oracle-ee-9\", \"oracle-ee-19\")) // true            \n}\n```\n\n## `LessThanWithTime`\nTo compare versions with associated times, such as create times, use `LessThanWithTime()`:\n\n```go\npackage main\n\nimport (\n    \"time\"\n\n    \"github.com/YakDriver/go-version\"\n)\n\nfunc main() {\n    time1 := time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC) // January 1, 2000 00:00:00UTC\n    time2 := time.Date(2024, time.January, 1, 0, 0, 0, 0, time.UTC) // January 1, 2024 00:00:00UTC\n    semVer1 := \"1.0.0\"\n    semVer2 := \"1.0.1\"\n\n    fmt.Printf(\"%t\\n\", version.LessThanWithTime(time1, time2, semVer1, semVer2)) // true\n    fmt.Printf(\"%t\\n\", version.LessThanWithTime(time1, time2, semVer2, semVer1)) // true (date only)\n    fmt.Printf(\"%t\\n\", version.LessThanWithTime(time2, time1, semVer1, semVer2)) // false\n    fmt.Printf(\"%t\\n\", version.LessThanWithTime(time1, time1, semVer1, semVer2)) // true (same time, check versions)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyakdriver%2Fgo-version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyakdriver%2Fgo-version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyakdriver%2Fgo-version/lists"}