src = src[j : len(src)];
}
- return buf.Data();
+ return buf.Bytes();
}
if html {
var buf bytes.Buffer;
fmt.Fprint(&buf, x);
- writeText(w, buf.Data(), true);
+ writeText(w, buf.Bytes(), true);
} else {
fmt.Fprint(w, x);
}
func htmlCommentFmt(w io.Writer, x interface{}, format string) {
var buf bytes.Buffer;
writeAny(&buf, x, false);
- doc.ToHtml(w, buf.Data());
+ doc.ToHtml(w, buf.Bytes());
}
if err := parseerrorHtml.Execute(errors, &buf); err != nil {
log.Stderrf("parseerrorHtml.Execute: %s", err);
}
- servePage(c, errors.filename + " - Parse Errors", buf.Data());
+ servePage(c, errors.filename + " - Parse Errors", buf.Bytes());
}
writeNode(&buf, prog, true);
fmt.Fprintln(&buf, "</pre>");
- servePage(c, name + " - Go source", buf.Data());
+ servePage(c, name + " - Go source", buf.Bytes());
}
if err := packageText.Execute(info, &buf); err != nil {
log.Stderrf("packageText.Execute: %s", err);
}
- serveText(c, buf.Data());
+ serveText(c, buf.Bytes());
return;
}
if path == "" {
path = "."; // don't display an empty path
}
- servePage(c, path + " - Go package documentation", buf.Data());
+ servePage(c, path + " - Go package documentation", buf.Bytes());
}
io.Copy(r, &buf);
wait, err := os.Wait(pid, 0);
if err != nil {
- os.Stderr.Write(buf.Data());
+ os.Stderr.Write(buf.Bytes());
log.Stderrf("os.Wait(%d, 0): %v\n", pid, err);
return false;
}
if !wait.Exited() || wait.ExitStatus() != 0 {
- os.Stderr.Write(buf.Data());
+ os.Stderr.Write(buf.Bytes());
log.Stderrf("executing %v failed (exit status = %d)", args, wait.ExitStatus());
return false;
}
if *verbose {
- os.Stderr.Write(buf.Data());
+ os.Stderr.Write(buf.Bytes());
}
if c != nil {
c.SetHeader("content-type", "text/plain; charset=utf-8");
- c.Write(buf.Data());
+ c.Write(buf.Bytes());
}
return true;
}
tw.Close();
- actual := buf.Data();
+ actual := buf.Bytes();
if !bytes.Equal(expected, actual) {
t.Errorf("test %d: Incorrect result: (-=expected, +=actual)\n%v",
i, bytediff(expected, actual));
encoder := NewEncoder(StdEncoding, bb);
encoder.Write(strings.Bytes(p.decoded));
encoder.Close();
- testEqual(t, "Encode(%q) = %q, want %q", p.decoded, string(bb.Data()), p.encoded);
+ testEqual(t, "Encode(%q) = %q, want %q", p.decoded, string(bb.Bytes()), p.encoded);
}
}
}
err := encoder.Close();
testEqual(t, "Close gave error %v, want %v", err, os.Error(nil));
- testEqual(t, "Encoding/%d of %q = %q, want %q", bs, bigtest.decoded, string(bb.Data()), bigtest.encoded);
+ testEqual(t, "Encoding/%d of %q = %q, want %q", bs, bigtest.decoded, string(bb.Bytes()), bigtest.encoded);
}
}
t.Errorf("%s: buf.Flush = %v", context, e);
}
- written := w.Data();
+ written := w.Bytes();
if len(written) != nwrite {
t.Errorf("%s: %d bytes written", context, len(written));
}
t.Error("WriteString", b.err);
}
s := "01234567890abcdefghijklmnopqrstuvwxyz";
- if string(buf.Data()) != s {
- t.Errorf("WriteString wants %q gets %q", s, string(buf.Data()))
+ if string(buf.Bytes()) != s {
+ t.Errorf("WriteString wants %q gets %q", s, string(buf.Bytes()))
}
}
off int; // read at &buf[off], write at &buf[len(buf)]
}
-// Data returns the contents of the unread portion of the buffer;
-// len(b.Data()) == b.Len().
-func (b *Buffer) Data() []byte {
+// Bytes returns the contents of the unread portion of the buffer;
+// len(b.Bytes()) == b.Len().
+func (b *Buffer) Bytes() []byte {
return b.buf[b.off : len(b.buf)]
}
+// String returns the contents of the unread portion of the buffer
+// as a string.
+func (b *Buffer) String() string {
+ return string(b.buf[b.off : len(b.buf)])
+}
+
// Len returns the number of bytes of the unread portion of the buffer;
-// b.Len() == len(b.Data()).
+// b.Len() == len(b.Bytes()).
func (b *Buffer) Len() int {
return len(b.buf) - b.off
}
// Verify that contents of buf match the string s.
func check(t *testing.T, testname string, buf *Buffer, s string) {
- if buf.Len() != len(buf.Data()) {
- t.Errorf("%s: buf.Len() == %d, len(buf.Data()) == %d\n", testname, buf.Len(), len(buf.Data()))
+ if buf.Len() != len(buf.Bytes()) {
+ t.Errorf("%s: buf.Len() == %d, len(buf.Bytes()) == %d\n", testname, buf.Len(), len(buf.Bytes()))
}
if buf.Len() != len(s) {
t.Errorf("%s: buf.Len() == %d, len(s) == %d\n", testname, buf.Len(), len(s))
}
- if string(buf.Data()) != s {
- t.Errorf("%s: string(buf.Data()) == %q, s == %q\n", testname, string(buf.Data()), s)
+ if string(buf.Bytes()) != s {
+ t.Errorf("%s: string(buf.Bytes()) == %q, s == %q\n", testname, string(buf.Bytes()), s)
}
}
if err != tt.err {
t.Errorf("%s: io.Copy: %v want %v", tt.name, err, tt.err);
}
- s := string(b.Data());
+ s := string(b.Bytes());
if s != tt.raw {
t.Errorf("%s: got %d-byte %q want %d-byte %q", tt.name, n, s, len(tt.raw), tt.raw);
}
}
continue;
}
- s := string(b.Data());
+ s := string(b.Bytes());
if s != tt.raw {
t.Errorf("%s: got %d-byte %q want %d-byte %q", tt.desc, n, s, len(tt.raw), tt.raw);
}
n, err := io.Copy(r, w);
if n != int64(len(tt.in)) || err != nil {
t.Errorf("%s: CBCEncrypter io.Copy = %d, %v want %d, nil", test, n, err, len(tt.in));
- } else if d := crypt.Data(); !same(tt.out, d) {
+ } else if d := crypt.Bytes(); !same(tt.out, d) {
t.Errorf("%s: CBCEncrypter\nhave %x\nwant %x", test, d, tt.out);
}
n, err = io.Copy(r, w);
if n != int64(len(tt.out)) || err != nil {
t.Errorf("%s: CBCDecrypter io.Copy = %d, %v want %d, nil", test, n, err, len(tt.out));
- } else if d := plain.Data(); !same(tt.in, d) {
+ } else if d := plain.Bytes(); !same(tt.in, d) {
t.Errorf("%s: CBCDecrypter\nhave %x\nwant %x", test, d, tt.in);
}
n, err := io.Copy(r, w);
if n != int64(len(tt.in)) || err != nil {
t.Errorf("%s: CFBEncrypter io.Copy = %d, %v want %d, nil", test, n, err, len(tt.in));
- } else if d := crypt.Data(); !same(tt.out, d) {
+ } else if d := crypt.Bytes(); !same(tt.out, d) {
t.Errorf("%s: CFBEncrypter\nhave %x\nwant %x", test, d, tt.out);
}
n, err = io.Copy(r, w);
if n != int64(len(tt.out)) || err != nil {
t.Errorf("%s: CFBDecrypter io.Copy = %d, %v want %d, nil", test, n, err, len(tt.out));
- } else if d := plain.Data(); !same(tt.in, d) {
+ } else if d := plain.Bytes(); !same(tt.in, d) {
t.Errorf("%s: CFBDecrypter\nhave %x\nwant %x", test, d, tt.in);
}
n, err := io.Copy(r, w);
if n != int64(len(in)) || err != nil {
t.Errorf("%s/%d: CTRWriter io.Copy = %d, %v want %d, nil", test, len(in), n, err, len(in));
- } else if d, out := crypt.Data(), tt.out[0:len(in)]; !same(out, d) {
+ } else if d, out := crypt.Bytes(), tt.out[0:len(in)]; !same(out, d) {
t.Errorf("%s/%d: CTRWriter\ninpt %x\nhave %x\nwant %x", test, len(in), in, d, out);
}
}
n, err := io.Copy(r, w);
if n != int64(len(out)) || err != nil {
t.Errorf("%s/%d: CTRReader io.Copy = %d, %v want %d, nil", test, len(out), n, err, len(out));
- } else if d, in := plain.Data(), tt.in[0:len(out)]; !same(in, d) {
+ } else if d, in := plain.Bytes(), tt.in[0:len(out)]; !same(in, d) {
t.Errorf("%s/%d: CTRReader\nhave %x\nwant %x", test, len(out), d, in);
}
}
if err != nil {
t.Fatalf("%s: enc.Close: %s", test, err);
}
- if d := b.Data(); !same(d, tt.cipher) {
+ if d := b.Bytes(); !same(d, tt.cipher) {
t.Fatalf("%s: got %x want %x", test, d, tt.cipher);
}
}
if n != int64(len(tt.msg)) || err != nil {
t.Fatalf("%s: io.Copy into decrypter: %d, %s", test, n, err);
}
- if d := b.Data(); !same(d, tt.msg) {
+ if d := b.Bytes(); !same(d, tt.msg) {
t.Fatalf("%s: got %x want %x", test, d, tt.msg);
}
}
n, err := io.Copy(r, w);
if n != int64(len(tt.in)) || err != nil {
t.Errorf("%s: ECBReader io.Copy = %d, %v want %d, nil", test, n, err, len(tt.in));
- } else if d := crypt.Data(); !same(tt.out, d) {
+ } else if d := crypt.Bytes(); !same(tt.out, d) {
t.Errorf("%s: ECBReader\nhave %x\nwant %x", test, d, tt.out);
}
n, err = io.Copy(r, w);
if n != int64(len(tt.out)) || err != nil {
t.Errorf("%s: ECBWriter io.Copy = %d, %v want %d, nil", test, n, err, len(tt.out));
- } else if d := plain.Data(); !same(tt.in, d) {
+ } else if d := plain.Bytes(); !same(tt.in, d) {
t.Errorf("%s: ECBWriter\nhave %x\nwant %x", test, d, tt.in);
}
}
// check output
- data := b.Data();
+ data := b.Bytes();
if len(data) != len(crypt) {
t.Errorf("block=%d frag=%d: want %d bytes, got %d", block, frag, len(crypt), len(data));
continue;
}
// check output
- data := b.Data();
+ data := b.Bytes();
if len(data) != maxio {
t.Errorf("%s: want %d bytes, got %d", test, maxio, len(data));
continue;
n, err := io.Copy(r, w);
if n != int64(len(in)) || err != nil {
t.Errorf("%s/%d: OFBWriter io.Copy = %d, %v want %d, nil", test, len(in), n, err, len(in));
- } else if d, out := crypt.Data(), tt.out[0:len(in)]; !same(out, d) {
+ } else if d, out := crypt.Bytes(), tt.out[0:len(in)]; !same(out, d) {
t.Errorf("%s/%d: OFBWriter\ninpt %x\nhave %x\nwant %x", test, len(in), in, d, out);
}
}
n, err := io.Copy(r, w);
if n != int64(len(out)) || err != nil {
t.Errorf("%s/%d: OFBReader io.Copy = %d, %v want %d, nil", test, len(out), n, err, len(out));
- } else if d, in := plain.Data(), tt.in[0:len(out)]; !same(in, d) {
+ } else if d, in := plain.Bytes(), tt.in[0:len(out)]; !same(in, d) {
t.Errorf("%s/%d: OFBReader\nhave %x\nwant %x", test, len(out), d, in);
}
}
// check output
crypt := crypt[0:len(crypt) - frag];
- data := b.Data();
+ data := b.Bytes();
if len(data) != len(crypt) {
t.Errorf("%s: want %d bytes, got %d", test, len(crypt), len(data));
continue;
}
// check output
- data := b.Data();
+ data := b.Bytes();
crypt := crypt[0:maxio - frag];
plain := plain[0:maxio - frag];
if len(data) != len(plain) {
if ch == '\n' || ch == '\f' {
// write text segment and indentation
n1, _ := s.output.Write(data[i0 : i+1]);
- n2, _ := s.output.Write(s.indent.Data());
+ n2, _ := s.output.Write(s.indent.Bytes());
n += n1 + n2;
i0 = i + 1;
s.linePos.Offset = s.output.Len();
// if the indentation evaluates to nil, the state's output buffer
// didn't change - either way it's ok to append the difference to
// the current identation
- s.indent.Write(s.output.Data()[mark.outputLen : s.output.Len()]);
+ s.indent.Write(s.output.Bytes()[mark.outputLen : s.output.Len()]);
s.restore(mark);
// format group body
}();
err := <- errors;
- return s.output.Data(), err;
+ return s.output.Bytes(), err;
}
if err != nil {
fmt.Fprintf(&buf, "--- Sprint(%s) failed: %v", fmt.Sprint(args), err);
}
- return string(buf.Data());
+ return string(buf.Bytes());
}
first = false;
}
fmt.Fprintf(b, "}");
- return string(b.Data())
+ return string(b.Bytes())
}
func (v *Map) Init() *Map {
case *bytes.Buffer:
// is io.Reader, but src is already available in []byte form
if s != nil {
- return s.Data(), nil;
+ return s.Bytes(), nil;
}
case io.Reader:
var buf bytes.Buffer;
if err != nil {
return nil, err;
}
- return buf.Data(), nil;
+ return buf.Bytes(), nil;
default:
return nil, os.ErrorString("invalid source");
}
if _, err := Fprint(&buf, prog, 0, tabwidth); err != nil {
t.Error(err);
}
- res := buf.Data();
+ res := buf.Bytes();
// update golden files if necessary
if *update {
if encState.err != nil {
t.Error("encodeUint:", tt.x, encState.err)
}
- if !bytes.Equal(tt.b, b.Data()) {
- t.Errorf("encodeUint: %#x encode: expected % x got % x", tt.x, tt.b, b.Data())
+ if !bytes.Equal(tt.b, b.Bytes()) {
+ t.Errorf("encodeUint: %#x encode: expected % x got % x", tt.x, tt.b, b.Bytes())
}
}
decState := newDecodeState(b);
instr := &encInstr{ encBool, 6, 0, 0 };
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
- if !bytes.Equal(boolResult, b.Data()) {
- t.Errorf("bool enc instructions: expected % x got % x", boolResult, b.Data())
+ if !bytes.Equal(boolResult, b.Bytes()) {
+ t.Errorf("bool enc instructions: expected % x got % x", boolResult, b.Bytes())
}
}
instr := &encInstr{ encInt, 6, 0, 0 };
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
- if !bytes.Equal(signedResult, b.Data()) {
- t.Errorf("int enc instructions: expected % x got % x", signedResult, b.Data())
+ if !bytes.Equal(signedResult, b.Bytes()) {
+ t.Errorf("int enc instructions: expected % x got % x", signedResult, b.Bytes())
}
}
instr := &encInstr{ encUint, 6, 0, 0 };
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
- if !bytes.Equal(unsignedResult, b.Data()) {
- t.Errorf("uint enc instructions: expected % x got % x", unsignedResult, b.Data())
+ if !bytes.Equal(unsignedResult, b.Bytes()) {
+ t.Errorf("uint enc instructions: expected % x got % x", unsignedResult, b.Bytes())
}
}
instr := &encInstr{ encInt8, 6, 0, 0 };
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
- if !bytes.Equal(signedResult, b.Data()) {
- t.Errorf("int8 enc instructions: expected % x got % x", signedResult, b.Data())
+ if !bytes.Equal(signedResult, b.Bytes()) {
+ t.Errorf("int8 enc instructions: expected % x got % x", signedResult, b.Bytes())
}
}
instr := &encInstr{ encUint8, 6, 0, 0 };
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
- if !bytes.Equal(unsignedResult, b.Data()) {
- t.Errorf("uint8 enc instructions: expected % x got % x", unsignedResult, b.Data())
+ if !bytes.Equal(unsignedResult, b.Bytes()) {
+ t.Errorf("uint8 enc instructions: expected % x got % x", unsignedResult, b.Bytes())
}
}
instr := &encInstr{ encInt16, 6, 0, 0 };
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
- if !bytes.Equal(signedResult, b.Data()) {
- t.Errorf("int16 enc instructions: expected % x got % x", signedResult, b.Data())
+ if !bytes.Equal(signedResult, b.Bytes()) {
+ t.Errorf("int16 enc instructions: expected % x got % x", signedResult, b.Bytes())
}
}
instr := &encInstr{ encUint16, 6, 0, 0 };
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
- if !bytes.Equal(unsignedResult, b.Data()) {
- t.Errorf("uint16 enc instructions: expected % x got % x", unsignedResult, b.Data())
+ if !bytes.Equal(unsignedResult, b.Bytes()) {
+ t.Errorf("uint16 enc instructions: expected % x got % x", unsignedResult, b.Bytes())
}
}
instr := &encInstr{ encInt32, 6, 0, 0 };
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
- if !bytes.Equal(signedResult, b.Data()) {
- t.Errorf("int32 enc instructions: expected % x got % x", signedResult, b.Data())
+ if !bytes.Equal(signedResult, b.Bytes()) {
+ t.Errorf("int32 enc instructions: expected % x got % x", signedResult, b.Bytes())
}
}
instr := &encInstr{ encUint32, 6, 0, 0 };
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
- if !bytes.Equal(unsignedResult, b.Data()) {
- t.Errorf("uint32 enc instructions: expected % x got % x", unsignedResult, b.Data())
+ if !bytes.Equal(unsignedResult, b.Bytes()) {
+ t.Errorf("uint32 enc instructions: expected % x got % x", unsignedResult, b.Bytes())
}
}
instr := &encInstr{ encInt64, 6, 0, 0 };
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
- if !bytes.Equal(signedResult, b.Data()) {
- t.Errorf("int64 enc instructions: expected % x got % x", signedResult, b.Data())
+ if !bytes.Equal(signedResult, b.Bytes()) {
+ t.Errorf("int64 enc instructions: expected % x got % x", signedResult, b.Bytes())
}
}
instr := &encInstr{ encUint64, 6, 0, 0 };
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
- if !bytes.Equal(unsignedResult, b.Data()) {
- t.Errorf("uint64 enc instructions: expected % x got % x", unsignedResult, b.Data())
+ if !bytes.Equal(unsignedResult, b.Bytes()) {
+ t.Errorf("uint64 enc instructions: expected % x got % x", unsignedResult, b.Bytes())
}
}
instr := &encInstr{ encFloat, 6, 0, 0 };
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
- if !bytes.Equal(floatResult, b.Data()) {
- t.Errorf("float enc instructions: expected % x got % x", floatResult, b.Data())
+ if !bytes.Equal(floatResult, b.Bytes()) {
+ t.Errorf("float enc instructions: expected % x got % x", floatResult, b.Bytes())
}
}
instr := &encInstr{ encFloat32, 6, 0, 0 };
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
- if !bytes.Equal(floatResult, b.Data()) {
- t.Errorf("float32 enc instructions: expected % x got % x", floatResult, b.Data())
+ if !bytes.Equal(floatResult, b.Bytes()) {
+ t.Errorf("float32 enc instructions: expected % x got % x", floatResult, b.Bytes())
}
}
instr := &encInstr{ encFloat64, 6, 0, 0 };
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
- if !bytes.Equal(floatResult, b.Data()) {
- t.Errorf("float64 enc instructions: expected % x got % x", floatResult, b.Data())
+ if !bytes.Equal(floatResult, b.Bytes()) {
+ t.Errorf("float64 enc instructions: expected % x got % x", floatResult, b.Bytes())
}
}
instr := &encInstr{ encUint8Array, 6, 0, 0 };
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
- if !bytes.Equal(bytesResult, b.Data()) {
- t.Errorf("bytes enc instructions: expected % x got % x", bytesResult, b.Data())
+ if !bytes.Equal(bytesResult, b.Bytes()) {
+ t.Errorf("bytes enc instructions: expected % x got % x", bytesResult, b.Bytes())
}
}
instr := &encInstr{ encString, 6, 0, 0 };
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
- if !bytes.Equal(bytesResult, b.Data()) {
- t.Errorf("string enc instructions: expected % x got % x", bytesResult, b.Data())
+ if !bytes.Equal(bytesResult, b.Bytes()) {
+ t.Errorf("string enc instructions: expected % x got % x", bytesResult, b.Bytes())
}
}
}
case "POST":
buf := new(bytes.Buffer);
io.Copy(req.Body, buf);
- body := string(buf.Data());
+ body := string(buf.Bytes());
if n, err := strconv.Atoi(body); err != nil {
fmt.Fprintf(c, "bad POST: %v\nbody: [%v]\n", err, body);
} else {
func ReadAll(r Reader) ([]byte, os.Error) {
var buf bytes.Buffer;
_, err := Copy(r, &buf);
- return buf.Data(), err;
+ return buf.Bytes(), err;
}
// ReadFile reads the file named by filename and returns the contents.
}
chr[0] = '"';
b.Write(chr0);
- return string(b.Data());
+ return string(b.Bytes());
}
var b bytes.Buffer;
io.Copy(r, &b);
- output := string(b.Data());
+ output := string(b.Bytes());
expect := "/\n";
if output != expect {
t.Errorf("exec /bin/pwd returned %q wanted %q", output, expect);
var b bytes.Buffer;
io.Copy(r, &b);
Wait(pid, 0);
- output := string(b.Data());
+ output := string(b.Bytes());
if n := len(output); n > 0 && output[n-1] == '\n' {
output = output[0:n-1];
}
// Copy the unmatched characters after the last match.
io.WriteString(buf, src[lastMatchEnd:len(src)]);
- return string(buf.Data());
+ return string(buf.Bytes());
}
// ReplaceAll returns a copy of src in which all matches for the Regexp
// Copy the unmatched characters after the last match.
buf.Write(src[lastMatchEnd:len(src)]);
- return buf.Data();
+ return buf.Bytes();
}
// QuoteMeta returns a string that quotes all regular expression metacharacters
switch {
default: // align left
- if err := b.write0(b.buf.Data()[pos : pos + c.size]); err != nil {
+ if err := b.write0(b.buf.Bytes()[pos : pos + c.size]); err != nil {
return pos, err;
}
pos += c.size;
return pos, err;
}
}
- if err := b.write0(b.buf.Data()[pos : pos + c.size]); err != nil {
+ if err := b.write0(b.buf.Bytes()[pos : pos + c.size]); err != nil {
return pos, err;
}
pos += c.size;
if i+1 == b.lines.Len() {
// last buffered line - we don't have a newline, so just write
// any outstanding buffered data
- if err := b.write0(b.buf.Data()[pos : pos + b.cell.size]); err != nil {
+ if err := b.write0(b.buf.Bytes()[pos : pos + b.cell.size]); err != nil {
return pos, err;
}
pos += b.cell.size;
b.buf.Write(text);
b.cell.size += len(text);
if updateWidth {
- b.cell.width += utf8.RuneCount(b.buf.Data()[b.pos : b.buf.Len()]);
+ b.cell.width += utf8.RuneCount(b.buf.Bytes()[b.pos : b.buf.Len()]);
b.pos = b.buf.Len();
}
}
func HtmlFormatter(w io.Writer, value interface{}, format string) {
var b bytes.Buffer;
fmt.Fprint(&b, value);
- HtmlEscape(w, b.Data());
+ HtmlEscape(w, b.Bytes());
}
t.Errorf("expected execute error %q, got %q", test.err, err.String());
}
}
- if string(buf.Data()) != test.out {
- t.Errorf("for %q: expected %q got %q", test.in, test.out, string(buf.Data()));
+ if string(buf.Bytes()) != test.out {
+ t.Errorf("for %q: expected %q got %q", test.in, test.out, string(buf.Bytes()));
}
}
}
if err != nil {
t.Error("unexpected execute error:", err)
}
- s := string(b.Data());
+ s := string(b.Bytes());
if s != "template: hello" {
t.Errorf("failed passing string as data: expected %q got %q", "template: hello", s)
}
if err != nil {
t.Error("unexpected parse error:", err)
}
- s := string(b.Data());
+ s := string(b.Bytes());
text := "template: hello";
if s != text {
t.Errorf("failed passing string as data: expected %q got %q", text, s);
if err != nil {
t.Error("unexpected parse error:", err)
}
- s = string(b.Data());
+ s = string(b.Bytes());
text += text;
if s != text {
t.Errorf("failed passing string as data: expected %q got %q", text, s);
}
var b bytes.Buffer;
err = tmpl.Execute("hello", &b);
- s := string(b.Data());
+ s := string(b.Bytes());
if s != "template: hello" + ldelim + rdelim {
t.Errorf("failed delim check(%q %q) %q got %q", ldelim, rdelim, text, s)
}
t.Fatal("unexpected execute error:", err)
}
expect := fmt.Sprintf("%v", &t1); // output should be hex address of t1
- if string(buf.Data()) != expect {
- t.Errorf("for %q: expected %q got %q", input, expect, string(buf.Data()));
+ if string(buf.Bytes()) != expect {
+ t.Errorf("for %q: expected %q got %q", input, expect, string(buf.Bytes()));
}
}