{"id":15647259,"url":"https://github.com/hairyhenderson/go-which","last_synced_at":"2025-04-28T16:10:18.357Z","repository":{"id":33943364,"uuid":"163672038","full_name":"hairyhenderson/go-which","owner":"hairyhenderson","description":"A cross-platform Go implementation of the which(1) command, usable both as a CLI and library","archived":false,"fork":false,"pushed_at":"2025-04-20T01:04:00.000Z","size":538,"stargazers_count":47,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-20T01:27:37.735Z","etag":null,"topics":["cli","cross-platform","go","go-package","golang","golang-cli","golang-library","hacktoberfest","library","shell"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/hairyhenderson/go-which","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/hairyhenderson.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-31T13:40:07.000Z","updated_at":"2025-04-20T01:04:03.000Z","dependencies_parsed_at":"2023-12-14T17:43:37.352Z","dependency_job_id":"e34c77ee-676f-41ad-adf5-068a4d5b92f7","html_url":"https://github.com/hairyhenderson/go-which","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/hairyhenderson%2Fgo-which","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hairyhenderson%2Fgo-which/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hairyhenderson%2Fgo-which/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hairyhenderson%2Fgo-which/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hairyhenderson","download_url":"https://codeload.github.com/hairyhenderson/go-which/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251342724,"owners_count":21574245,"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":["cli","cross-platform","go","go-package","golang","golang-cli","golang-library","hacktoberfest","library","shell"],"created_at":"2024-10-03T12:17:55.183Z","updated_at":"2025-04-28T16:10:18.337Z","avatar_url":"https://github.com/hairyhenderson.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-which\n\n[![Build Status][build-image]][build-url]\n[![hairyhenderson/go-which on DockerHub][dockerhub-image]][dockerhub-url]\n[![GoDoc][godoc-image]][godocs]\n\nA cross-platform Go implementation of the `which(1)` command, usable both as a CLI and library.\n\n```console\nUsage of which:\n  -a    List all instances of executables found (instead of just the first).\n  -s    No output, just return 0 if all executables are found, or 1 if some were not found.\n  -v    Print the version\n```\n\nUnlike the UNIX `which(1)` command, even if multiple programs are given as input, only the first one found will be returned.\n\n## CLI Usage\n\nChances are you don't really need this, since most UNIX-like OSes come with the more established (and significantly smaller) C implementation of `which(1)`, either as a standalone binary, or as a shell builtin.\n\n_But_ if there's some reason this may be useful to you, you can use this just like the normal `which(1)`:\n\n```console\n$ which zsh\n/usr/local/bin/zsh\n$ which -a zsh\n/usr/local/bin/zsh\n/bin/zsh\n```\n\n```console\n$ which zsh bash sh\n/usr/local/bin/zsh\n$ which -a zsh bash sh\n/usr/local/bin/zsh\n/bin/zsh\n/bin/bash\n/bin/sh\n```\n\n```console\n$ if (which -s zsh bash); then\n\u003e echo 'I have zsh and bash installed';\n\u003e fi\nI have zsh and bash installed\n$ if (which -s zsh bash ash); then echo 'yup'\n\u003e else\n\u003e echo \"I'm missing one of them...\";\n\u003e fi\nI'm missing one of them...\n```\n\n## Go package usage\n\nIf you're writing a program in the Go language, it can be useful to not have to shell out to `which(1)` to locate a binary.\n\nThe simplest usage is:\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"github.com/hairyhenderson/go-which\"\n)\n\nfunc main() {\n  zshPath := which.Which(\"zsh\")\n\n  fmt.Printf(\"zsh found at %s\", zshPath)\n}\n```\n\nSee the [godocs][] for more information.\n\n## License\n\n[The MIT License](http://opensource.org/licenses/MIT)\n\nCopyright (c) 2018-2020 Dave Henderson\n\n[godocs]: https://pkg.go.dev/github.com/hairyhenderson/go-which\n\n[build-image]: https://github.com/hairyhenderson/go-which/actions/workflows/build.yml/badge.svg\n[build-url]: https://github.com/hairyhenderson/go-which/actions/workflows/build.yml\n[dockerhub-image]: https://img.shields.io/badge/docker-ready-blue.svg\n[dockerhub-url]: https://hub.docker.com/r/hairyhenderson/go-which\n[godoc-image]: https://godoc.org/github.com/hairyhenderson/go-which?status.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhairyhenderson%2Fgo-which","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhairyhenderson%2Fgo-which","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhairyhenderson%2Fgo-which/lists"}