package os
import (
"errors"
"internal/poll"
"internal/testlog"
"io"
"runtime"
"syscall"
"time"
)
the os package import a few other packages.
file, err := os.Open("file.go") // For read access. if err != nil { log.Fatal(err) }
// Open opens the named file for reading. If successful, methods on
// the returned file can be used for reading; the associated file
// descriptor has mode O_RDONLY.
// If there is an error, it will be of type *PathError.
func Open(name string) (*File, error) {
return OpenFile(name, O_RDONLY, 0)
}
Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. If there is an error, it will be of type *PathError.
type File
File represents an open file descriptor.
type File struct {
// contains filtered or unexported fields
}
file, err := os.Open("file.go") // For read access.
file variable is the file descriptor which has mode O_RDONLY
Note: Next, read contents of pointer type by file variable name