{"id":36440229,"url":"https://github.com/puttsk/hostlist","last_synced_at":"2026-01-11T21:53:35.490Z","repository":{"id":204725658,"uuid":"711880422","full_name":"puttsk/hostlist","owner":"puttsk","description":"Go library for hostlist expression","archived":false,"fork":false,"pushed_at":"2023-11-28T18:49:47.000Z","size":34,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-27T09:44:28.759Z","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/puttsk.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}},"created_at":"2023-10-30T11:09:23.000Z","updated_at":"2023-11-28T18:57:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"a8a2ef1f-5ee9-4cb7-ba58-fd1c06393c08","html_url":"https://github.com/puttsk/hostlist","commit_stats":null,"previous_names":["puttsk/hostlist"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/puttsk/hostlist","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puttsk%2Fhostlist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puttsk%2Fhostlist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puttsk%2Fhostlist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puttsk%2Fhostlist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/puttsk","download_url":"https://codeload.github.com/puttsk/hostlist/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puttsk%2Fhostlist/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28324397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T18:42:50.174Z","status":"ssl_error","status_checked_at":"2026-01-11T18:39:13.842Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2026-01-11T21:53:34.670Z","updated_at":"2026-01-11T21:53:35.482Z","avatar_url":"https://github.com/puttsk.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-hostlist\n\nGo utility for hostlist expression.\n\n## Installation\n\n```bash\ngo get github.com/puttsk/hostlist\n```\n\n## Hostlist Expression\n\nHostlist expression is an expression for specifying a group of hostnames with in various applications, including utilities like [pdsh](https://code.google.com/archive/p/pdsh/wikis/HostListExpressions.wiki) and resource managers like [Slurm](https://slurm.schedmd.com/slurm.conf.html#OPT_NodeAddr). This expression allows the concise representation of multiple hostnames. For instance, the expression `host-[001-003]` is a shorthand for `host-001`, `host-002`,and `host-003`.\n\nIn the given example, `[001-003]` is referred to as a *range expression*. This expression defines a range of values in the format `[i-j,n-m,..]`, where `i`,`j`,`n`,and `m` are integer with the contraint `i \u003c j`, and `n \u003c m`. Although a range expression can accommodate string values, it does not support character ranges like `[a-c]`.\n\nExample of valid range expression: `[1-10,11,100-101]`, `[a,b,c]`, `[a,22-25]`\n\n## Usage\n\nHostlist package contains two main functions `Expand` and `Compress`.\n\n`Expand` recieves a hostlist expression and returns a list of hostname contained in the expression.\n\n**Example:**\n\n```go\nhosts, err := hostlist.Expand(\"host-[001-003]\")\nif err != nil {\n    fmt.Print(\"Error: \" + err.Error())\n}\n\n// Print host-001 host-002 host-003\nfmt.Printf(\"%s\\n\", strings.Join(hosts, \" \")) \n```\n\n`Compress` recieves a list of hostnames and return a hostlist expression representing the list.\n\n**Example:**\n\n```go\nhosts := []string{\"host-001\",\"host-oo2\",\"host-003\"}\nexpr, _ := hostlist.Compress(hosts)\n\n// Print host-[001-003]\nfmt.Println(expr)\n```\n\n## Command Line Interface\n\n```bash\n\u003e hostlist -h\nUsage of ./hostlist:\n  -c    See. -compress\n  -compress\n        Compress list of hostnames to hostlist expression\n  -e    See. -expand\n  -expand\n        Expand hostlist expression\n```\n\n### Expand hostlist expression\n\n```bash\n\u003e hostlist -e \"host[001-004]\"\nhost001 host002 host003 host004\n\n\u003e hostlist -e \"192.168.[0-1].[211-213]\"\n192.168.0.211 192.168.0.212 192.168.0.213 192.168.1.211 192.168.1.212 192.168.1.213\n```\n\n### Compress hostlist expression\n\n```bash\n\u003e hostlist -c host001 host002 host003 host004 \nhost[001-004]\n\n\u003e hostlist -c 192.168.0.211 192.168.0.212 192.168.0.213 192.168.1.211 192.168.1.212 192.168.1.213\n192.168.[0-1].[211-213]\n```\n\n## Contributing\n\nTBD\n\n## Authors\n\n* **Putt Sakdhnagool** - *Initial work*\n\nSee also the list of [contributors](https://github.com/puttsk/hostlist/graphs/contributors) who participated in this project.\n\n## Issues / Feature request\n\nYou can submit bug / issues / feature request using [Tracker](https://github.com/puttsk/hostlist/issues).\n\n## Known Issues\n\n* Current implementation of `Expand` does not accept a nested range expression, e.g., `[01-02,a[03-04]]`\n* The result of `Expand` an hostlist expression following by `Compress` might not results in the same input hostlist expression.\n* In some scenario, `Compress` generates nested range expression, which is not supported by `Expand` function\n\n## License\n\nMIT License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fputtsk%2Fhostlist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fputtsk%2Fhostlist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fputtsk%2Fhostlist/lists"}