ktimeout_test.go 388 B

123456789101112131415161718192021222324
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. package ktimeout
  4. import (
  5. "context"
  6. "fmt"
  7. "net"
  8. "time"
  9. )
  10. func ExampleUserTimeout() {
  11. lc := net.ListenConfig{
  12. Control: UserTimeout(30 * time.Second),
  13. }
  14. l, err := lc.Listen(context.TODO(), "tcp", "127.0.0.1:0")
  15. if err != nil {
  16. fmt.Printf("error: %v", err)
  17. return
  18. }
  19. l.Close()
  20. // Output:
  21. }