Answer the question
In order to leave comments, you need to log in
How to parse many files with TailFile?
To track log files I use TailFile (github.com/hpcloud/tail)
For one file it looks like this
t, err := tail.TailFile(v, tail.Config{Follow: true, ReOpen: true, MustExist: true})
var t = map[int]string
for k, value := range config.Settings.Logs {
t[k], err := tail.TailFile(value, tail.Config{Follow: true, ReOpen: true, MustExist: true})
}
./main.go:37:6: type map[int]string is not an expression
./main.go:40:4: non-name t[k] on left side of :=
Answer the question
In order to leave comments, you need to log in
var t = map[int]string
You are not trying to declare an array, but a hashmap. Correct like this:
But you would also like the option with a slice:
var t []string
for k, value := range config.Settings.Logs {
elem, err := tail.TailFile(value, tail.Config{Follow: true, ReOpen: true, MustExist: true})
...... тут надо ошибку проверить .....
t = append(t, elem)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question