Стоян обнови решението на 30.10.2015 00:42 (преди над 2 години)
+package main
+
+import (
+ "fmt"
+ "strings"
+)
+
+func ExtractColumn(logContents string, column uint8) string{
+ logs := strings.SplitAfter(logContents, "\n")
+ result := ""
+ for i :=0; i < len(logs); i++ {
+ if ( len(logs[i]) >1){
+ result = result + ExtractColumnHelper(logs[i], column) + "\n"
+ }
+ }
+ return result
+}
+
+func ExtractColumnHelper(logContents string, column uint8) string {
+ buffer := strings.Split(logContents, " ")
+ size := 0
+ i := 0
+ str := ""
+ if column == 0{
+ size = 2
+ i = 0
+ } else if column == 1 {
+ size = 3
+ i = 2
+ }else {
+ i =3
+ size = len(buffer)
+ }
+ for ; i < size; i++ {
+ str = str + buffer[i]
+ }
+ return str
+}
+func main() {
+ fmt.Printf("Hello World\n")
+
+}