func readAndCompare(conn *net.UnixConn, want string) error { buf := make([]byte, 128) // File system events can take a long time to propagate conn.SetDeadline(time.Now().Add(3 * time.Second)) if _, _, err := conn.ReadFrom(buf); err != nil { return err } if have := string(bytes.Trim(buf, "\x00")); have != want { return fmt.Errorf("expected %q, got %q", want, have) } return nil }