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

huangapple go评论99阅读模式
英文:

Running all files in directory, what is go run ./cmd/*.go?

问题

我目前正在查看这个项目(Mattermost),其中的Makefile文件有一行让我感到困惑:

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

./cmd/platform/*.go 的意思是什么?具体执行哪些文件?当我在终端中输入这个命令时,程序可以正常执行。

我正在尝试在一个集成开发环境(IDE)中输入命令行参数,但我需要一个特定的入口文件.....

英文:

I am currently looking at this project (Mattermost) that has a certain line in the makefile that I'm confused about:

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

What is the meaning of ./cmd/platform/*.go? What specific files are executed? The program executes correctly when I type it in the terminal.

I am trying to enter the command line arguments in an IDE but I need a specific entry file.....

答案1

得分: 0

Wikipedia

glob (programming)

在计算机编程中,特别是在类Unix环境中,通配符模式(glob patterns)用于指定带有通配符字符的文件名集合。例如,Unix命令mv *.txt textfiles/将当前目录中以.txt结尾的所有文件移动(mv)到目录textfiles中。在这里,是一个通配符,代表"任意字符串",而.txt是一个通配符模式。另一个常见的通配符是问号(?),代表一个字符。

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

在Linux上,ls ./cmd/platform/*.go命令将列出这些文件。

因此,go run ./cmd/platform/*.go命令会编译并运行这些Go(*.go)源文件。请参阅Command go文档:编译和运行Go程序

英文:

> 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.

Clearly, ./cmd/platform/*.go, starting in the current directory, looks in the cmd/platform directory for files matching the wildcard *.go.

The ls ./cmd/platform/*.go command will list the files on Linux.

So, the go run ./cmd/platform/*.go command compiles and runs these Go (*.go) source files. See Command go documentation: Compile and run Go program.

huangapple
  • 本文由 发表于 2017年5月11日 00:36:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/43898245.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定