Hey Community,
I know, there are so many discussion about error handling. I read tons of
idea about that. Looks like most of idea rejected from community but every
idea brings our goal closer.
May be we need simple solution. I like Go's simplest ways always. I don't
think so we need complex solution about that. Could we handle complexity
the error checking with simple throws statement?
func myFileRDWRFunc(filename string) (string, error) {
f, err := os.OpenFile(filename, os.O_RDWR, 0600)
if err != nil { // backward compatibility
return "", err
}
throws func(err error) { // catch all errors
log.Println(err)
f.Close()
return "", err
}()
f.WriteString("anystring")
f.Seek(0, 0)
b := ioutil.ReadAll(f)
return string(b), nil
}
Cheers.
Semih.
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/242e536c-1a85-4855-a64e-a41f67889e0eo%40googlegroups.com.