package conn import ( "fmt" "net" ) const ( Port = ":3030" Type = "tcp4" ) func StartSimple(handler func(conn net.Conn)) error { l, err := net.Listen(Type, Port) if err != nil { return err } defer l.Close() fmt.Println(fmt.Sprintf("Listening on port %s", Port)) for { c, err := l.Accept() if err != nil { return err } go handler(c) err = c.Close() if err != nil { return err } } }