gpt4 book ai didi

go - 运行目录下的所有文件,什么是go run ./cmd/*.go?

转载 作者:IT王子 更新时间:2023-10-29 02:22:00 26 4
gpt4 key购买 nike

我目前正在查看这个项目 ( Mattermost ),它在 makefile 中有一行让我感到困惑:

$(GO) run $(GOFLAGS) $(GO_LINKER_FLAGS) ./cmd/platform/*.go --disableconfigwatch &

./cmd/platform/*.go是什么意思?执行了哪些具体文件?当我在终端中输入程序时,程序会正确执行。

我正在尝试在 IDE 中输入命令行参数,但我需要一个特定的输入文件......

最佳答案

Wikipedia

glob (programming)

In computer programming, in particular in a Unix-like environment, glob patterns specify sets of filenames with wildcard characters. For example, the Unix command mv *.txt textfiles/ moves (mv) all files with names ending in .txt from the current directory to the directory textfiles. Here, * is a wildcard standing for "any string of characters" and *.txt is a glob pattern. The other common wildcard is the question mark (?), which stands for one character.

显然,./cmd/platform/*.go 从当前目录开始,在 cmd/platform 目录中查找与通配符 匹配的文件*.go.

ls ./cmd/platform/*.go 命令将列出 Linux 上的文件。

因此,go run ./cmd/platform/*.go 命令编译并运行这些 Go (*.go) 源文件。参见 Command go文档:Compile and run Go program .

关于go - 运行目录下的所有文件,什么是go run ./cmd/*.go?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43898245/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com