gcloud_identity_token/
shared.rs1use std::sync::OnceLock;
2
3static PORT: OnceLock<u16> = OnceLock::new();
4
5pub fn get_or_init_port() -> u16 {
6 *PORT.get_or_init(|| {
7 std::net::TcpListener::bind("127.0.0.1:0")
8 .expect("Failed to bind to ephemeral port")
9 .local_addr()
10 .unwrap()
11 .port()
12 })
13}