您的位置 首页 golang

以后台形式运行golang程序

安装:

 go get github.com/icattlecoder/godaemon
  

示例:

 package main

import (
    _ "github.com/icattlecoder/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 
hello, golang!  

文章来源:智云一二三科技

文章标题:以后台形式运行golang程序

文章地址:https://www.zhihuclub.com/99597.shtml

关于作者: 智云科技

热门文章

评论已关闭

4条评论

  1. We have extensive experience and made our site as clear as possible so that you can quickly and easily buy Nolvadex online

网站地图