News for hackers. Stuff that matters.
Re:The Reliability of Go by hornetblack on Sunday October 20, 2013 @08:37PM (#6582348)
If I attempt to grab the result of a function eg:

    f := os.Create(fname)
    defer(f.Close())
It won't compile as `os.Create` returns `(file, error)`. So you must either:

    // Proper error handling
    f, err := os.Create(fname)
    if err != nil {
        log.Fatalf("Could not create '%s'", fname)
        // Well may want to do something other than crash.
    }
    defer(f.close())
    
If you ignore the error it's obvious

    f, _ := os.Create(fname)
    defer(f.Close())
It's like doing this in Java

    File f;
    try {
        f = new File(fname);
    } catch (Exception e) {
        // Ignore Exception
    }
Re:The Reliability of Go by drbawb on Monday October 21, 2013 @03:51PM (#6587787)
Possibly worth pointing out to non-gophers: in `Go` it is illegal to declare an unused variable.

So if you write `f, err := os.Create("/bad/path");`, and that is the first time `err` has been declared & used in that scope, you can't just let `err` go unused or your program won't compile.