Дамян обнови решението на 29.10.2015 14:07 (преди над 2 години)
+package main
+
+import "strings"
+
+func GetLogRows(logContents string) (logRows []string) {
+ logRows = strings.Split(logContents, "\n")
+ if logRows[len(logRows)-1] == "" {
+ logRows = logRows[:(len(logRows) - 1)]
+ }
+ return
+}
+
+func ExtractColumn(logContents string, column uint8) (logColumn string) {
+ for _, row := range GetLogRows(logContents) {
+ if row == "" {
+ break
+ }
+ if column == 0 {
+ logColumn += strings.SplitN(row, " ", 4)[0] + " " + strings.SplitN(row, " ", 4)[1] + "\n"
+ } else {
+ logColumn += strings.SplitN(row, " ", 4)[column+1] + "\n"
+ }
+ }
+ return
+}