OXIESEC PANEL
- Current Dir:
/
/
opt
/
golang
/
1.19.4
/
src
/
testing
/
iotest
Server IP: 2a02:4780:11:1084:0:327f:3464:10
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
12/01/2022 06:13:56 PM
rwxr-xr-x
📄
example_test.go
469 bytes
12/01/2022 06:13:01 PM
rw-r--r--
📄
logger.go
1.26 KB
12/01/2022 06:13:01 PM
rw-r--r--
📄
logger_test.go
3.42 KB
12/01/2022 06:13:01 PM
rw-r--r--
📄
reader.go
7.94 KB
12/01/2022 06:13:01 PM
rw-r--r--
📄
reader_test.go
6.14 KB
12/01/2022 06:13:01 PM
rw-r--r--
📄
writer.go
674 bytes
12/01/2022 06:13:01 PM
rw-r--r--
📄
writer_test.go
876 bytes
12/01/2022 06:13:01 PM
rw-r--r--
Editing: writer.go
Close
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package iotest import "io" // TruncateWriter returns a Writer that writes to w // but stops silently after n bytes. func TruncateWriter(w io.Writer, n int64) io.Writer { return &truncateWriter{w, n} } type truncateWriter struct { w io.Writer n int64 } func (t *truncateWriter) Write(p []byte) (n int, err error) { if t.n <= 0 { return len(p), nil } // real write n = len(p) if int64(n) > t.n { n = int(t.n) } n, err = t.w.Write(p[0:n]) t.n -= int64(n) if err == nil { n = len(p) } return }