N
N
Newmo2020-02-12 17:01:19
go
Newmo, 2020-02-12 17:01:19

How to output the required line from the file?

There is a txt file, and the line number in the file is also known. How to output a string by its number?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vlarkanov, 2020-02-12
@Newmo

Are you lazy to google?

configFile, err := ioutil.ReadFile("./config")

  if err != nil {
      log.Fatal(err)
  }

  configLines := strings.Split(string(configFile), "\n")

Then from configLines display the required line by its number.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question