github.com/LukasHeimann/cloudfoundrycli/v8@v8.4.4/integration/helpers/random_port.go (about)

     1  package helpers
     2  
     3  var previouslyUsedPort int
     4  
     5  // RandomPort returns a port number that has not yet been used, starting at 1024 and
     6  // increasing by one each time it is called. It errors if the number increases above 1123.
     7  func RandomPort() int {
     8  	if previouslyUsedPort == 0 {
     9  		previouslyUsedPort = 1024
    10  		return previouslyUsedPort
    11  	}
    12  
    13  	previouslyUsedPort++
    14  	if previouslyUsedPort > 1123 {
    15  		panic("all ports used, figure out how to fix this future us")
    16  	}
    17  
    18  	return previouslyUsedPort
    19  }