Note to use the value in range for when you want to execute something in another go routine. In the following code snippet, the bs means a set of address. Note the sentence bCap := b which make sure the err = http3.ListenAndServe(bCap, certFile, keyFile, handler) will receive a expected value when it's executing.
for _, b := range bs {
bCap := b
go func() {
var err error
if *tcp {
err = http3.ListenAndServe(bCap, certFile, keyFile, handler)
} else {
server := http3.Server{
Handler: handler,
Addr: bCap,
QuicConfig: quicConf,
}
err = server.ListenAndServeTLS(certFile, keyFile)
}
if err != nil {
fmt.Printf("failed to listen and serve at %s: %s\n", bCap, err)
os.Exit(-1)
}
}()
}
Note to use the value in range for when you want to execute something in another go routine. In the following code snippet, the
bs
means a set of address. Note the sentencebCap := b
which make sure theerr = http3.ListenAndServe(bCap, certFile, keyFile, handler)
will receive a expected value when it's executing.