tListenAndServe in a goroutine - tordam - A library for peer discovery inside the Tor network
 (HTM) git clone https://git.parazyd.org/tordam
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 9b22c43c76f6b74a58f06bdc6544977e6d77e582
 (DIR) parent 7a697d4ef254930b0eb9f9c7da12af1415ede4fd
 (HTM) Author: parazyd <parazyd@dyne.org>
       Date:   Thu,  7 Dec 2017 19:19:23 +0100
       
       ListenAndServe in a goroutine
       
       Diffstat:
         M go/ddir/ddir.go                     |       9 ++++++++-
       
       1 file changed, 8 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/go/ddir/ddir.go b/go/ddir/ddir.go
       t@@ -6,6 +6,7 @@ import (
                "encoding/json"
                "log"
                "net/http"
       +        "sync"
        
                "../lib"
        )
       t@@ -40,7 +41,13 @@ func handlePost(rw http.ResponseWriter, request *http.Request) {
        }
        
        func main() {
       +        var wg sync.WaitGroup
       +
                http.HandleFunc("/announce", handlePost)
       -        http.ListenAndServe(ListenAddress, nil)
       +
       +        wg.Add(1)
       +        go http.ListenAndServe(ListenAddress, nil)
                log.Println("Listening on", ListenAddress)
       +
       +        wg.Wait()
        }