Skip to content

Commit

Permalink
feat: return tcp.Address from listener, if exists (#336)
Browse files Browse the repository at this point in the history
* This is the more accurate and correct address of the listener
* Useful if you want to listen on port 0 to dynamically create
listeners (think of unit/integration tests)

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
  • Loading branch information
AeroNotix and mochi-co authored Dec 21, 2023
1 parent c6c7c29 commit 5523d15
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions listeners/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ func (l *TCP) ID() string {

// Address returns the address of the listener.
func (l *TCP) Address() string {
if l.listen != nil {
return l.listen.Addr().String()
}
return l.address
}

Expand Down

0 comments on commit 5523d15

Please sign in to comment.