code.go 400 B

12345678910111213141516171819202122232425262728
  1. package main
  2. import (
  3. "fmt"
  4. "io/ioutil"
  5. "log"
  6. "os"
  7. "strings"
  8. )
  9. func readInput(file string) []string {
  10. content, err := ioutil.ReadFile(file)
  11. if err != nil {
  12. log.Fatal(err)
  13. }
  14. lines := strings.Split(string(content), "\n")
  15. return lines
  16. }
  17. func main() {
  18. if len(os.Args) < 2 {
  19. log.Fatal("You need to provide path to input file!")
  20. }
  21. lines := readInput(os.Args[1])
  22. fmt.Println(lines)
  23. }