1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 // TruncateWriter returns a Writer that writes to w
13 // but stops silently after n bytes.
14 func TruncateWriter(w io
.Writer
, n
int64) io
.Writer
{
15 return &truncateWriter
{w
, n
}
18 type truncateWriter
struct {
23 func (t
*truncateWriter
) Write(p
[]byte) (n
int, err os
.Error
) {
32 n
, err
= t
.w
.Write(p
[0:n
])