I am trying to fix these errors in my golang code, and if someone can help me, I would appreciate it.
Here is my code: http://play.golang.org/p/yELWfIdWz5
However, the one that bothers me the most is the first on line 21, where the error says: syntax error: unexpected semicolon or new line before another. I cannot find a semicolon or a new line or immediately before line 21.
In addition to what the errors on lines 28 and 32 mean (an operator outside the declaration outside the function body) - these operators are in the main () function, and the last closing bracket closes this function, so why is there an error ?.
I have a feeling that all these mistakes are related to the first.
I would really appreciate any help in solving these problems, or at least more about them.
Here is the code:
package main import "fmt" func main() { var current_mid = "" current_topic := make(map[string][]string) f, err := os.Open(*inputFile) if err != nil { fmt.Println(err) return } r := bufio.NewReader(f) xmlFile, _ := os.Create("freebase.xml") line, err := r.ReadString('\n') for err == nil{ subject, predicate, object := parseTriple(line) if subject == current_mid{ current_topic[predicate] = append(current_topic[predicate], object) } else if len(current_mid) > 0{ processTopic(current_mid, current_topic, xmlFile) current_topic = make(map[string][]string) } current_mid = subject line, err = r.ReadString('\n') } processTopic(current_mid, current_topic, xmlFile) if err != io.EOF { fmt.Println(err) return } }
source share