Permissions
Ports <= 1024 are privileged ports. You can't use them unless you're root or have the explicit
permission to use them. See this answer for an explanation or wikipedia or something
you trust more.
See this answer for a solution to allow your application to open these ports without
giving them superuser permissions (which is a bad idea). Money Quote:
sudo setcap 'cap_net_bind_service=+ep' /opt/yourGoBinary
Blocking
ListenAndServe
and its TLS counterpart ListeAndServeTLS
are blocking.
The http handler returned by gorest.Handle()
is executed concurrently when /
is accessed.
If you want to have other code running concurrently, start a goroutine before running ListeAndServe
or implement different http handlers.
Example using goroutines:
func printStuff() {
time.Sleep(1 * time.Second)
fmt.Println("foo")
}
func main() {
go printSTuff()
log.Fatal(http.ListeAndServe(":80"))
}