The io.reader and buffer size are passed as arguments in this function. The primary goal of this function is to read the data in larger chunks instead of line by line and store in buffer.
This function belongs to Go's bufio package. The function then returns the final array of strings as a result.
This function is present in strings package and it accepts the string to split as an argument along with a separator. Split() function is used to split a string through a provided separator. Syntax func Split(str, sep string) string In the first Example, we will use NewReader function from the bufio package, in the second Example we will use ReadFile function from ioutil package and in the third Example we will use file.Read function respectively. In this article, we will use three Examples to read lines from the existing file. In Go programming language, Bufio and io package functions will be used to read the text from the given file.