方法1:
windows 只需要在编译的时候使用一下go build - ldflags="-H windows"
Linux 在运行程序的尾部加入&,或者nohup ./example &
导入一个包即可。
_ "github.com/codyguo/godaemon"
使用方法:
./example -d=true 或者 ./example -d true
详细参考:http://github.com/codyguo/godaemon
博客介绍了让Go程序在后台运行的两种方法。方法一是在不同系统操作,Windows编译时用go build -ldflags=\-H windows\,Linux运行程序尾部加&或nohup./example &;方法二推荐导入包_ \github.com/codyguo/godaemon\,使用./example -d=true或./example -d true,还给出详细参考链接。
方法1:
windows 只需要在编译的时候使用一下go build - ldflags="-H windows"
Linux 在运行程序的尾部加入&,或者nohup ./example &
导入一个包即可。
_ "github.com/codyguo/godaemon"
使用方法:
./example -d=true 或者 ./example -d true
详细参考:http://github.com/codyguo/godaemon
953
333