Марио обнови решението на 02.11.2015 20:20 (преди над 2 години)
+package main
+
+import "strings"
+import "fmt"
+
+func ExtractColumn(logContents string, column uint8) string {
+ lines := strings.Split(logContents, "\n")
+ values := make([]string, 0, len(lines))
+ for _, line := range lines {
+ if line == "" {
+ continue
+ }
+
+ entries := strings.SplitN(line, " ", 4)
+ if column == 0 {
+ values = append(values, fmt.Sprintf("%s %s\n", entries[0], entries[1]))
+ } else {
+ values = append(values, fmt.Sprintf("%s\n", entries[column+1]))
+ }
+ }
+ return strings.Join(values, "")
+}