Skip to content
Myr

Abort fzf if --listen port is unavailable

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 6d14573 · Browse files · 2 files+9 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+9 added−4 removed

  • other:+9 added−4 removed

2 files+9 added−4 removed

modified:src/server.go+5 added-3 removed
14 unmodified lines
15 httpOk = "HTTP/1.1 200 OK" + crlf16 httpBadRequest = "HTTP/1.1 400 Bad Request" + crlf17)1819func startHttpServer(port int, channel chan []*action) {19func startHttpServer(port int, channel chan []*action) error {20 if port == 0 {21 return21 return nil22 }2324 listener, err := net.Listen("tcp", fmt.Sprintf(":%d", port))25 if err != nil {26 return26 return fmt.Errorf("port not available: %d", port)27 }2829 go func() {30 for {
9 unmodified lines
40 conn.Close()41 }42 listener.Close()43 }()4445 return nil46}4748// Here we are writing a simplistic HTTP server without using net/http49// package to reduce the size of the binary.
65 unmodified lines
modified:src/terminal.go+4 added-1 removed
619 unmodified lines
620 }621 t.separator, t.separatorLen = t.ansiLabelPrinter(bar, &tui.ColSeparator, true)622 }623624 if err := startHttpServer(t.listenPort, t.serverChan); err != nil {625 errorExit(err.Error())626 }627628 return &t629}630631func borderLines(shape tui.BorderShape) int {
1871 unmodified lines
25032504 looping := true2505 _, startEvent := t.keymap[tui.Start.AsEvent()]25062503 startHttpServer(t.listenPort, t.serverChan)2507 eventChan := make(chan tui.Event)2508 needBarrier := true2509 barrier := make(chan bool)2510 go func() {
691 unmodified lines