News for hackers. Stuff that matters.
Re:Golang landmines by barsonme on Saturday September 17, 2016 @08:16PM (#12523227)
I disagree. Return interfaces where it makes sense. E.g., returning

    type Buffer interface {
        io.Writer
        io.ByteWriter
        WriteString(string) (int, error)
        ...
    }
from `bytes.NewBuffer' would be a bit absurd. But returning an interface (`io.Reader') from `io.MultiReader' makes more sense than returning some sort of structure.

I think the author was getting at how one should always return explicit zero values _or_ explicit non-zero. E.g.,

    func GetACat() (Cat, error) {
        cat, err := getCatInternalOrSomething()
        if err != nil {
            return nil, err
        }
        return cat, nil
    }

There are no comments on this comment yet.