用go写windows系统服务

用go+nssm非常容易实现windows系统服务,先看下面的程序

package main

func main() {
 //Call this function where the action happpens
 doStuff()
}

func doStuff() {
 for {
  //the actual stuff happens here.
 }
}

下载nssm复制到c:\windows目录,执行

nssm install MyService d:\MyService.exe

nssm下载地址:http://nssm.cc/description

参考http://sanatgersappa.blogspot.co.id/2013/07/windows-service-with-go-easy-way.html