Reuse buffer

This commit is contained in:
Torjus Håkestad 2022-02-22 20:26:02 +01:00
parent 8b49d09725
commit 46dc100b37

View File

@ -43,8 +43,8 @@ func main() {
} }
defer l.Close() defer l.Close()
buf := make([]byte, 1024)
for { for {
buf := make([]byte, 1024)
n, raddr, err := l.ReadFrom(buf) n, raddr, err := l.ReadFrom(buf)
log.Printf("received packet %d\n", n) log.Printf("received packet %d\n", n)