Read method, one take []byte slice argument. Return two values namely n int type and err error type. In this example, an assumption that the file already opens with os.Open(). a make initializes the variable on a slice of []byte type with has a quantity of 100 of memory of bytes size (uint8 – unsigned… Continue reading os package Reading from the opened file.
Category: os
Package os provides a platform-independent interface to operating system functionality. The design is Unix-like, although the error handling is Go-like; failing calls return values of type error rather than error numbers. Often, more information is available within the error. For example, if a call that takes a file name fails, such as Open or Stat, the error will include the failing file name when printed and will be of type *PathError, which may be unpacked for more information.
The os interface is intended to be uniform across all operating systems. Features not generally available appear in the system-specific package syscall.
os package with reading an open file and error log
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… Continue reading os package with reading an open file and error log
https://golang.org/pkg/os Args variable
Args hold the command-line arguments, starting with the program name. var Args []string