Version: v0.0.0-...-1a7aca4 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2018 License: MIT Imports: 4 Imported by: 0




This section is empty.


This section is empty.


func Fprintf

func Fprintf(w io.Writer, format string, args ...interface{})

Fprintf behaves exactly like Printf but it writes the formatted output to the specified io.Writer.

func GetOutputSink

func GetOutputSink() io.Writer

GetOutputSink returns the default target for calls to Printf.

func Panic

func Panic(e interface{})

Panic outputs the supplied error (if not nil) to the console and halts the CPU. Calls to Panic never return. Panic also works as a redirection target for calls to panic() (resolved via runtime.gopanic)

func Printf

func Printf(format string, args ...interface{})

Printf provides a minimal Printf implementation that can be safely used before the Go runtime has been properly initialized. This implementation does not allocate any memory.

Similar to fmt.Printf, this version of printf supports the following subset of formatting verbs:


%s the uninterpreted bytes of the string or byte slice


%o base 8
%d base 10
%x base 16, with lower-case letters for a-f


%t "true" or "false"

Width is specified by an optional decimal number immediately preceding the verb. If absent, the width is whatever is necessary to represent the value.

String values with length less than the specified width will be left-padded with spaces. Integer values formatted as base-10 will also be left-padded with spaces. Finally, integer values formatted as base-16 will be left-padded with zeroes.

Printf supports all built-in string and integer types but assumes that the Go itables have not been initialized yet so it will not check whether its arguments support io.Stringer if they don't match one of the supported tupes.

This function does not provide support for printing pointers (%p) as this requires importing the reflect package. By importing reflect, the go compiler starts generating calls to runtime.convT2E (which calls runtime.newobject) when assembling the argument slice which obviously will crash the kernel since memory management is not yet available.

The output of Printf is written to the currently active TTY. If no TTY is available, then the output is buffered into a ring-buffer and can be retrieved by a call to FlushRingBuffer.

func SetOutputSink

func SetOutputSink(w io.Writer)

SetOutputSink sets the default target for calls to Printf to w and copies any data accumulated in the earlyPrintBuffer to itt .


type PrefixWriter

type PrefixWriter struct {
	// A writer where all writes get sent to.
	Sink io.Writer

	// The prefix injected at the beginning of each line.
	Prefix []byte
	// contains filtered or unexported fields

PrefixWriter is an io.Writer that wraps another io.Writer and injects a prefix at the beginning of each line.

func (*PrefixWriter) Write

func (w *PrefixWriter) Write(p []byte) (int, error)

Write writes len(p) bytes from p to the underlying data stream and returns back the number of bytes written. The PrefixWriter keeps track of the beginning of new lines and injects the configured prefix at each new line. The injected prefix is not included in the number of written bytes returned by this method.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL