Created
December 21, 2020 09:44
-
-
Save hoangnt-2197/4fc3089706e58ef298d4667162d04060 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
file, err := os.Open("./planets.txt") | |
if err != nil { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
defer file.Close() | |
reader := bufio.NewReader(file) | |
for { | |
line, err := reader.ReadString('\n') | |
if err != nil { | |
if err == io.EOF { | |
break | |
} else { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
} | |
fmt.Print(line) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment