Documentation ¶
Overview ¶
Package prefixw provides a writer which puts prefix each lines.
Example ¶
package main import ( "os" "github.com/koron-go/prefixw" ) func main() { w := prefixw.New(os.Stdout, "PREFIX ") w.Write([]byte("Hello\nWorld\n")) }
Output: PREFIX Hello PREFIX World
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer implements io.Writer with prefix each lines.
func (*Writer) Close ¶
Close flushes buffered data and closes Writer.
Example ¶
package main import ( "os" "github.com/koron-go/prefixw" ) func main() { w1 := prefixw.New(os.Stdout, "PREFIX1 ") w1.Write([]byte("Hello\nSufficient\nWorld")) w1.Close() w2 := prefixw.New(os.Stdout, "PREFIX2 ") w2.Write([]byte("Hello\nInsufficient\nWorld")) }
Output: PREFIX1 Hello PREFIX1 Sufficient PREFIX1 World PREFIX2 Hello PREFIX2 Insufficient
func (*Writer) Write ¶
Write writes data to base Writer with prefix.
Example ¶
package main import ( "os" "github.com/koron-go/prefixw" ) func main() { w1 := prefixw.New(os.Stdout, "PREFIX1 ") w1.Write([]byte("Hello\nSufficient")) w1.Write([]byte("World\n")) w2 := prefixw.New(os.Stdout, "PREFIX2 ") w2.Write([]byte("Hello\nInsufficient")) w2.Write([]byte("World")) }
Output: PREFIX1 Hello PREFIX1 SufficientWorld PREFIX2 Hello
Click to show internal directories.
Click to hide internal directories.