// 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 iotestimport ()type writeLogger struct { prefix string w io.Writer}func ( *writeLogger) ( []byte) ( int, error) { , = .w.Write()if != nil {log.Printf("%s %x: %v", .prefix, [0:], ) } else {log.Printf("%s %x", .prefix, [0:]) }return}// NewWriteLogger returns a writer that behaves like w except// that it logs (using [log.Printf]) each write to standard error,// printing the prefix and the hexadecimal data written.func ( string, io.Writer) io.Writer {return &writeLogger{, }}type readLogger struct { prefix string r io.Reader}func ( *readLogger) ( []byte) ( int, error) { , = .r.Read()if != nil {log.Printf("%s %x: %v", .prefix, [0:], ) } else {log.Printf("%s %x", .prefix, [0:]) }return}// NewReadLogger returns a reader that behaves like r except// that it logs (using [log.Printf]) each read to standard error,// printing the prefix and the hexadecimal data read.func ( string, io.Reader) io.Reader {return &readLogger{, }}
The pages are generated with Goldsv0.7.0-preview. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.