I am trying to start two http server on different ports, but unable to use the same pattern:
handlerFunc1 := http.HandlerFunc(hello1)
http.Handle("/", handlerFunc1)
server1 := &http.Server{
Addr: "localhost:8081",
Handler: handlerFunc1,
}
go server1.ListenAndServe()
http.HandleFunc("/", hello2)
go http.ListenAndServe(":8082", nil)
Do you know how, I have tried using(as you can see) http.Server
and http.ListenAndServe
Well for any other progressive developer this works:
Thanks to @mkopriva's comment: