Empty return in func with return value in golang

Viewed 38974

I was reading some code written in Golang on Github and found a very interesting piece of code. I simplified it to be clear.

func  Insert(docs ...interface{}) (err error) {
    for i := 0; i < 3; i++ {
        err = fmt.Errorf("")
        if err.Error()!="EOF" {
            return
        }
    }
    return 
}

I'm very confused about empty return here... How it works? Does he return nil as error or breaks for loop? I understand that this question looks dummy, but I cannot find any info on this in go docs... Also, I don't understand how we can return err, which is, as I understood, declared somehow in return. Does (err error) means that we already have an error variable available in our func which is used as default return value if none specified? Why then we implicitly make return err at the end of func?

I'll be very gratefull for explanation.

3 Answers
Related