hairyhenderson/go-which

GitHub: hairyhenderson/go-which

跨平台的 Go 语言版 `which(1)` 命令实现,可作为 CLI 工具和 Go 库使用,用于在系统 PATH 中查找可执行文件路径。

Stars: 51 | Forks: 2

# go-which [![Build Status](https://static.pigsec.cn/wp-content/uploads/repos/cas/3b/3b39c55110f11a97d10cda63d1c1193c1b78ee3e26d559adaea16b191fc65e8a.svg)][build-url] [![hairyhenderson/go-which on DockerHub](https://img.shields.io/badge/docker-ready-blue.svg)][dockerhub-url] [![GoDoc](https://godoc.org/github.com/hairyhenderson/go-which?status.svg)][godocs] 一个跨平台的 Go 语言版 `which(1)` 命令实现,可作为 CLI 和库使用。 ``` Usage of which: -a List all instances of executables found (instead of just the first). -s No output, just return 0 if all executables are found, or 1 if some were not found. -v Print the version ``` 与 UNIX 的 `which(1)` 命令不同,即使输入了多个程序,也只会返回找到的第一个程序。 ## CLI 用法 您可能并不真正需要它,因为大多数类 UNIX 操作系统都自带了更为成熟(且体积明显更小)的 C 语言版 `which(1)` 实现,既可以作为独立的二进制文件,也可以作为 shell 内置命令。 *但是*,如果出于某种原因它对您有用,您可以像使用普通的 `which(1)` 一样使用它: ``` $ which zsh /usr/local/bin/zsh $ which -a zsh /usr/local/bin/zsh /bin/zsh ``` ``` $ which zsh bash sh /usr/local/bin/zsh $ which -a zsh bash sh /usr/local/bin/zsh /bin/zsh /bin/bash /bin/sh ``` ``` $ if (which -s zsh bash); then > echo 'I have zsh and bash installed'; > fi I have zsh and bash installed $ if (which -s zsh bash ash); then echo 'yup' > else > echo "I'm missing one of them..."; > fi I'm missing one of them... ``` ## Go 包用法 如果您正在使用 Go 语言编写程序,能够免去通过 shell 外部调用 `which(1)` 来定位二进制文件的麻烦,将会非常有用。 最简单的用法是: ``` package main import ( "fmt" "github.com/hairyhenderson/go-which" ) func main() { zshPath := which.Which("zsh") fmt.Printf("zsh found at %s", zshPath) } ``` 有关更多信息,请参阅 [godocs][]。 ## 许可证 [The MIT License](http://opensource.org/licenses/MIT) Copyright (c) 2018-2020 Dave Henderson
标签:EVTX分析, 文档结构分析, 日志审计, 请求拦截