func main(){
runtime.GOMAXPROCS(runtime.NumCPU())
r := mux.NewRouter()
www := r.Host("secure.domain.com").Subrouter()
www.HandleFunc("/", Handler_www)
api := r.Host("api.domain.com").Subrouter()
api.HandleFunc("/", Handler_api)
go func(){
cert := "/var/ini/ssl/secure.domain.com/intermediate.crt"
prv_key := "/var/ini/ssl/secure.domain.com/private.key"
err := http.ListenAndServeTLS(":9443", cert, prv_key, r)
if err != nil {
log.Fatal("HTTPS server: ", err)
}
}
err := http.ListenAndServe(":9000", r)
if err != nil {
log.Fatal("HTTP server: ", err)
}
}
答案 0 :(得分:2)
在结束()
后尝试添加}
。
这样,您实际上会调用func()
。
go func(){
cert := "/var/ini/ssl/secure.domain.com/intermediate.crt"
prv_key := "/var/ini/ssl/secure.domain.com/private.key"
err := http.ListenAndServeTLS(":9443", cert, prv_key, r)
if err != nil {
log.Fatal("HTTPS server: ", err)
}
}()