如何通过命令行运行当前目录下的所有.go文件(多文件包) [英] How to run all .go files within current directory through the command line (multi file package)

查看:52
本文介绍了如何通过命令行运行当前目录下的所有.go文件(多文件包)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Go 的新手.我非常喜欢这种语言,但我很快意识到由于程序大小的增加,我需要开始分割我的文件.

I'm a newcomer to Go. I extremely like the language, but I quickly realised that I needed to start dividing my files due to an increase in program size.

go run main.go(main.go 是我的 main() 函数的文件)

go run main.go (with main.go having been the file with my main() function)

没有工作,我遇到了一段时间的障碍,因为我不知道如何让我的程序工作.

didn't work and I hit a barrier for a while, because I had no clue how to get my program working.

一些快速搜索让我找到了

Some quick searching lead me to the answer of

go run main.go other.go ..

通过输入我的 package main 包含的所有文件,我可以让程序运行.然而,每次这样做都非常麻烦和令人沮丧.

where by typing all the files that my package main consists of, I could get the programming running. However, this is utterly cumbersome and frustrating to do each time.

我写了以下自我回答的问题,以防止像我这样的其他人再次遇到这个障碍.

I write the following self-answered question in order to prevent others like myself who may again hit this barrier.

推荐答案

现在终于可以使用了:

go run .

感谢:https://github.com/golang/go/issues/22726#issuecomment-345841019

这篇关于如何通过命令行运行当前目录下的所有.go文件(多文件包)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆