I researched Go's io.Writer interface.
io.Writer
is the following interface.
type Writer interface {
Write(p []byte) (n int, err error)
}
It has a write method.
--File input / output --Write to connection --Write to buffer
There are various write methods such as.
This is because the above write method is implemented in file, TCPConn, and Buffer.
You can write to each file
.
Earlier, I used the phrase file
, but there is a file descriptor
.
This is the OS abstraction mechanism provided at the kernel layer
.
Specifically, it's like a numeric identifier
--0: Standard input --1: Standard output -2: Standard error output
The corresponding one is decided for each numerical value like.
There are various corresponding ones such as sockets as well as files. However, all of them can be accessed and written in the same way as files, so It is abstracted with the idea of a `file. ``
This io.Writer
imitates a file descriptor and is implemented in Go language.
Thank you very much. -Entrance to low-level access (1): io.Writer
Recommended Posts