メモメモ os.Stdout

// os.Stdout implements Writer
w = os.Stdout

fmt.Fprintf(w, "hello, writer\n")

-----------------------------------------------------------------------------

<- http://golang.org/pkg/os/#pkg-variables

Package os

Variables

var (
        Stdin  = NewFile(uintptr(syscall.Stdin), "/dev/stdin")
        Stdout = NewFile(uintptr(syscall.Stdout), "/dev/stdout")
        Stderr = NewFile(uintptr(syscall.Stderr), "/dev/stderr")
)

Stdin, Stdout, and Stderr are open Files pointing to the standard input, standard output, and standard error file descriptors.

 

<- http://golang.org/pkg/os/#NewFile

func NewFile

func NewFile(fd uintptr, name string) *File

NewFile returns a new File with the given file descriptor and name.

type File

type File struct {
        // contains filtered or unexported fields
}

File represents an open file descriptor.

 

func (*File) Write

func (f *File) Write(b []byte) (n int, err error)

Write writes len(b) bytes to the File. It returns the number of bytes written and an error, if any. Write returns a non-nil error when n != len(b).

 

<- syscall - The Go Programming Language

Package syscall

Overview ▾

Package syscall contains an interface to the low-level operating system primitives. The details vary depending on the underlying system, and by default, godoc will display the syscall documentation for the current system.

 

<- http://golang.org/pkg/syscall/#pkg-variables

Variables

var (
        Stdin  = 0
        Stdout = 1
        Stderr = 2
)

 

<- https://golang.org/pkg/fmt/#Fprintf

func Fprintf

func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error)

Fprintf formats according to a format specifier and writes to w. It returns the number of bytes written and any write error encountered.

 

<- http://golang.org/pkg/io/#Writer

Package io

type Writer

type Writer interface {
        Write(p []byte) (n int, err error)
}

Writer is the interface that wraps the basic Write method.

Write writes len(p) bytes from p to the underlying data stream. It returns the number of bytes written from p (0 <= n <= len(p)) and any error encountered that caused the write to stop early. Write must return a non-nil error if it returns n < len(p). Write must not modify the slice data, even temporarily.

 

<- http://golang.org/pkg/syscall/#Write

func Write

func Write(fd int, p []byte) (n int, err error)

<- https://golang.org/src/syscall/syscall_unix.go

148 func Write(fd int, p []byte) (n int, err error) {
149 if raceenabled {
150 raceReleaseMerge(unsafe.Pointer(&ioSync))
151 }
152 n, err = write(fd, p)
153 if raceenabled && n > 0 {
154 raceReadRange(unsafe.Pointer(&p[0]), n)
155 }
156 return
157 }