When you write: f, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
the types of 'f' and 'err' are defined statically and magically as whatever the declared return types of os.OpenFile are. It's like you wrote: var f type1 var err type2 f, err = os.OpenFile(...) where type1 and type2 were replaced by looking at the function definition of os.OpenFile. "return f, err" will then assign those values to the return types *your* function declared - which are *os.File and error respectively. So if "f" or "err" are of the wrong type, you'll get a compile-time error, meaning you can't even build your program, let alone run it. Example: https://play.golang.org/p/IOLMmMUGjCL Therefore, there's no point checking the type of "f", since the compiler has already done this. The interesting one is "err". You are returning type "error", which is an interface type. This means that "err" can have any concrete type which satisfies that interface, and it will work. Example: https://play.golang.org/p/Hdb9smP9hYh -- 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/7cd5fcfb-8be2-42e6-991e-769c1188ae05%40googlegroups.com.