Go has an http server built in so there’s no requirement to use Nginx or Apache to run your code on a server. To be able to serve your code on a server is to use http.ListenAndServe()

ListenAndServe takes a few params that are required for it to work.

  • Port - it can be a string or :http or :http-alt. In case of the former, it will go to etc/services file when starting the server or it will return an error when nothing has been matched.
  • router MUX (Go Router).