Check the port availability by trying to bind and immediately release it.
(port int)
| 135 | |
| 136 | // Check the port availability by trying to bind and immediately release it. |
| 137 | func checkPort(port int) error { |
| 138 | l, err := net.Listen("tcp", fmt.Sprintf("0.0.0.0:%d", port)) |
| 139 | if err != nil { |
| 140 | return err |
| 141 | } |
| 142 | return l.Close() |
| 143 | } |
| 144 | |
| 145 | func start() { |
| 146 | handlerOptions := &slog.HandlerOptions{AddSource: true, Level: log.LogLevel, ReplaceAttr: log.Replace} |