Run golang app as background program, 以后台形式运行golang
go get github.com/CodyGuo/godaemon
package main
import (
_ "github.com/CodyGuo/godaemon"
"log"
"net/http"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/index", func(rw http.ResponseWriter, req *http.Request) {
rw.Write([]byte("hello, golang!\n"))
})
log.Fatalln(http.ListenAndServe(":7070", mux))
}
./example -d=true
~$ curl http://127.0.0.1:7070/index
hello, golang!