{"id":16195119,"url":"https://github.com/ashcrow/osrelease","last_synced_at":"2025-03-19T04:30:51.398Z","repository":{"id":57499153,"uuid":"103163238","full_name":"ashcrow/osrelease","owner":"ashcrow","description":"Go library/binary for parsing osrelease","archived":false,"fork":false,"pushed_at":"2018-06-27T13:46:46.000Z","size":9,"stargazers_count":3,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T03:51:14.759Z","etag":null,"topics":["command-line","freedesktop","golang","golang-library","library","osrelease"],"latest_commit_sha":null,"homepage":null,"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/ashcrow.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":"2017-09-11T16:56:36.000Z","updated_at":"2025-03-11T15:04:56.000Z","dependencies_parsed_at":"2022-08-28T15:21:03.220Z","dependency_job_id":null,"html_url":"https://github.com/ashcrow/osrelease","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashcrow%2Fosrelease","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashcrow%2Fosrelease/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashcrow%2Fosrelease/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashcrow%2Fosrelease/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ashcrow","download_url":"https://codeload.github.com/ashcrow/osrelease/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244357478,"owners_count":20440336,"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":["command-line","freedesktop","golang","golang-library","library","osrelease"],"created_at":"2024-10-10T08:26:19.371Z","updated_at":"2025-03-19T04:30:51.011Z","avatar_url":"https://github.com/ashcrow.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# osrelease - Go library/binary for parsing osrelease\n\nSee the\n[os-release](https://www.freedesktop.org/software/systemd/man/os-release.html)\ndocumentation.\n\n## Building\n\n```bash\nmake deps      # Install dependencies\n...\nmake osrelease # Create the binary\n...\n```\n\n## Usage\n\n**Note**: ``OSRelease`` type directly supports fields as defined by the\n``os-release`` documentation. Fields that are present but are not\nexplicitly part of said documentation are added in ``ADDITIONAL_FIELDS``.\nWhen using the command line binary these fields are accesses the same\nway as supported fields. When using osrelease as a library to find unsupported\nfields ``ADDITIONAL_FIELDS`` (``map[string]string``) will need to be searched.\n\n### Command Line\n```bash\n# A single field\n./osrelease field ID\nfedora$\n\n# A field that is not considered part of the supported set\n./osrelease field REDHAT_BUGZILLA_PRODUCT_VERSION\n26$\n\n# A field that doesn't exist\n$ ./osrelease field idonotexist\n$ echo $?\n1\n\n# In a format\n./osrelease yaml\nname: Fedora\nversion: 26 (Workstation Edition)\nid: fedora\n...\n$\n```\n\n\n### Library\n\n\n```golang\n\nimport (\n\t\"errors\"\n\n\t\"github.com/ashcrow/osrelease\"\n)\n\nfunc RequireFedora() error {\n\t// The OSRelease instance using the default paths\n\tor, err := osrelease.New(nil)\n\t// Or to inspect the files in /sysroot\n\t//or, err := osrelease.NewWithOverrides(\"/sysroot/etc/osrelease\", \"/tmp/someplace/usr/lib/os-release\"))\n\t// Handle the error however you see fit\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif or.ID != \"fedora\" {\n\t\treturn errors.New(\"Fedora Linux is a requirement\")\n\t}\n\n\t// Everything is fine\n\treturn nil\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashcrow%2Fosrelease","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashcrow%2Fosrelease","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashcrow%2Fosrelease/lists"}