Your "throws" statement (why is it called "throws" when it "catches" according to the comment?) looks a lot like the "handle" block from the first draft design by the Go team: the check/handle proposal <https://go.googlesource.com/proposal/+/master/design/go2draft-error-handling.md> .
On Friday, 31 July 2020 at 16:06:33 UTC+2 semi...@gmail.com wrote: > 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 golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/9b52a293-eb4c-462b-9d64-56a345348a5cn%40googlegroups.com.