func writeLogfile(g *graph.Graph, round int) error { logfile := filepath.Join(*outputDir, fmt.Sprintf("%04d.def", round)) f, err := os.Create(logfile) if err != nil { return fmt.Errorf("Error creating logfile: %v", err) } def := g.GraphDef() data, err := encoding.Marshal(def) if err != nil { return fmt.Errorf("Error marshalling graph def: %v", err) } _, err = f.Write(data) return err }