github.com/bored-engineer/go-launchd@v0.0.0-20230905041514-6aff1185c30f/example/agent.go (about) 1 package main 2 3 import ( 4 "io" 5 "log" 6 "net" 7 8 launchd "github.com/bored-engineer/go-launchd" 9 ) 10 11 func main() { 12 l, err := launchd.Activate("Listeners") 13 if err != nil { 14 log.Fatalf("launchd.Socket failed: %s", err) 15 } 16 for { 17 conn, err := l.Accept() 18 if err != nil { 19 log.Printf("(net.Listener).Accept failed: %s", err) 20 continue 21 } 22 go func(conn net.Conn) { 23 defer func() { 24 conn.Close() 25 }() 26 io.Copy(conn, conn) 27 }(conn) 28 } 29 }