/// diff compares a and b.
        void Diff(string aname, string bname, slice <byte> a, slice <byte> b)
        {
            var buf = new GoBuffer(); // holding long error message

            // compare lengths
            if (a.Length != b.Length)
            {
                buf.WriteString($"\nlength changed: len({aname}) = {a.Length},"
                                + " len({bname}) = {b.Length}");
            }

            // compare contents
            var line = 1;
            var offs = 1;

            for (var i = 0; i < a.Length && i < b.Length; i++)
            {
                var ch = a[i];
                if (ch != b[i])
                {
                    buf.WriteString(string.Format("\n{0}:{1}:{2}: {3}", aname, line, i - offs + 1,
                                                  LineAt(a, offs)));
                    buf.WriteString(string.Format("\n{0}:{1}:{2}: {3}", bname, line, i - offs + 1,
                                                  LineAt(b, offs)));
                    buf.WriteString("\n\n");
                    break;
                }
                if (ch == '\n')
                {
                    line++;
                    offs = i + 1;
                }
            }

            if (buf.Len() > 0)
            {
                throw new IOException(buf.ToString());
            }
        }