英文:
Install a go script to run from shell
问题
我有一个名为SSL_CHECK.go
的Go脚本。现在要运行它,我需要使用go run SSL_CHECK.go <<可选参数>>
命令。
我想将这个脚本编译成可在shell中执行的命令。
例如,像这样从shell中执行:./ssl_check <<可选参数>>
。
我能在Go中实现这个吗?
英文:
I have a go script named SSL_CHECK.go
. Now to run it I need to run it as go run SSL_CHECK.go <<optiional arguments>>
I want to compile this script so that I can execute it as a shell command.
For instance like ./ssl_check <<optional arguments>>
from the shell.
Can I achieve that in Go.
答案1
得分: 0
如果你的SSL_CHECK.go
文件在main
包中,你只需要执行go install
命令(就像在"编译和安装包及其依赖项"中所述)。
这将生成一个名为SSH_CHECK
的可执行文件,并将其放置在$GOPATH/bin
文件夹中,该文件夹应该在你的$PATH
中被引用。
英文:
If you SSL_CHECK.go is in the package main, all you need to do is go install
(as in "Compile and install packages and dependencies").
That will generate a SSH_CHECK
executable and put it in your $GOPATH/bin
folder, which should be referenced in your $PATH
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论