What's the difference? If I use net/http/fcgi package, every request will be executed in new goroutine. It seems to be the same for net/http ListenAndServe...isn't it? What advantages and disadvantages?
The net/http/fcgi
allows you to listen via the FastCGI protocol for new connections whereas the net/http
ListenAndServe is there for listening for incoming http connections. With a FastCGI listener you need an http server sitting in front of the Go process that is proxying incoming connections and sending requests via FastCGI to you Go process.
FastCGi can be useful if you have multiple services that you need to expose on the same port. You can run something like Apache or Nginx as the front end and expose certain urls to your Go process via FastCGI.
If this is not your case and you just want to run a Go web server on a port, stick with net/http
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With