2 ms·
You get a syntax error, "no new variables on left side of :=". You could do: _ = http.ListenAndServe(*port, nil) But why would you? Just omit it entirely
by drivebyacct2 14y ago
You get a syntax error, "no new variables on left side of :=".
You could do:
_ = http.ListenAndServe(*port, nil)
But why would you? Just omit it entirely. The only time you need to explicitly ignore errors is in multiple returns.
consider: http://play.golang.org/p/o8vLQQmRvp http://play.golang.org/p/o8vLQQmRvp
which would be fixed like: http://play.golang.org/p/DH0j1cwRqW http://play.golang.org/p/DH0j1cwRqW
But yes, since ListenAndServe is normally used to block before main() returns, you could let it fail and terminate. (But you'd probably want to exit with a non-zero value, at least I would).