What is the purpose of this change? What does it change?
When used in scripts it can be useful to start a server with an ephemeral port number (e.g. a free port selected automatically by the application).
rest-server already does this (it's handled by net.Listen()), but the current code doesn't print the selected port - rather it prints the requested port (0).
This changes the behaviour to print the address returned by net.Listen.
This is useful when the server is started with an ephemeral port, e.g. previously running:
./rest-server --no-auth --listen "127.0.0.1:0"
would print:
start server on 127.0.0.1:0
With this change the output now shows the actual port selected, e.g.
start server on 127.0.0.1:46015
Was the change discussed in an issue or in the forum before?
No. For such a simple change, I thought it would less effort to go straight to a PR. Happy to make changes if needed.
What is the purpose of this change? What does it change?
When used in scripts it can be useful to start a server with an ephemeral port number (e.g. a free port selected automatically by the application).
rest-server
already does this (it's handled bynet.Listen()
), but the current code doesn't print the selected port - rather it prints the requested port (0
).This changes the behaviour to print the address returned by
net.Listen
.This is useful when the server is started with an ephemeral port, e.g. previously running:
would print:
With this change the output now shows the actual port selected, e.g.
Was the change discussed in an issue or in the forum before?
No. For such a simple change, I thought it would less effort to go straight to a PR. Happy to make changes if needed.
Checklist
changelog/unreleased/
that describes the changes for our users (template here)gofmt
on the code in all commits