Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
package main
import (
func main() {
file, err := os.Open("filetoread.txt")
if err != nil {
defer file.Close()
scanner := bufio.NewScanner(file)
// Returns a boolean based on whether there's a next instance of `\n`
// character in the IO stream. This step also advances the internal pointer
// to the next position (after '\n') if it did find that token.
read := scanner.Scan()
if read {
fmt.Println("read byte array: ", scanner.Bytes())
fmt.Println("read string: ", scanner.Text())
// goto line number 30 and repeat