golang 另类方法后台运行程序(linux、windows)

来源:互联网 发布:帝国数据库备份目录 编辑:程序博客网 时间:2024/05/16 14:58

后台运行程序

方法1:

windows 只需要在编译的时候使用一下go build - ldflags="-H windows"

Linux  在运行程序的尾部加入&,或者nohup ./example &

方法2:

导入一个包即可。

_  "github.com/codyguo/godaemon"

使用方法:

./example -d=true 或者 ./example -d true


方法来自于:https://github.com/icattlecoder/godaemon,仅支持-d=true的参数输入方法。

http://github.com/codyguo/godaemon,支持-d=true和-d true。





0 0
原创粉丝点击