github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/graceful/net_windows.go (about)

     1  // Copyright 2023 The GitBundle Inc. All rights reserved.
     2  // Copyright 2017 The Gitea Authors. All rights reserved.
     3  // Use of this source code is governed by a MIT-style
     4  // license that can be found in the LICENSE file.
     5  
     6  // This code is heavily inspired by the archived gofacebook/gracenet/net.go handler
     7  
     8  //go:build windows
     9  
    10  package graceful
    11  
    12  import "net"
    13  
    14  // GetListener obtains a listener for the local network address.
    15  // On windows this is basically just a shim around net.Listen.
    16  func GetListener(network, address string) (net.Listener, error) {
    17  	// Add a deferral to say that we've tried to grab a listener
    18  	defer GetManager().InformCleanup()
    19  
    20  	return net.Listen(network, address)
    21  }