save custom struct.. and It fail
package main
import (
"encoding/gob"
"os"
)
type Person struct {
Title string
}
type Persons []Person
func (p *Persons) add(pp Person) {
*p = append(*p, Person{pp.Title})
}
func IdxSave( page Persons) {
f, err := os.Open("./example.gob")
if err != nil {
panic("cant open file")
}
defer f.Close()
enc := gob.NewEncoder(f)
if err := enc.Encode(page); err != nil {
panic("cant encode")
}
}
func main() {
IdxSave(Persons{Person{"Hans"}})
}
when I see the log. it say " bad file descriptor" and some go routine which
I can't understand
how can I solved?
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.