On Sat, 2023-04-22 at 15:31 -0700, jlfo...@berkeley.edu wrote: > What type should I use to declare “file” in the parameter list for > myfunc()? As a new Go programmer I have to admit that I haven’t > memorized all the types used in the Go standard library. So, I have > to break off working on myfunc() to look up the type returned by > os.Open(). This isn’t a huge deal, but it’s a distraction and can > waste time. I suppose that as I gain experience with Go, I’ll have to > do this less and less.
LSP will let you know, but to provide a counterpoint... The type that the function should take may not be the concrete type, func myfunc(file ...) might be func myfunc(f *os.File) or func myfunc(r io.Reader) or any of a number of other interfaces that *os.File satisfies. The choice here is not necessarily defined by the type, but more by the intention of the programmer. -- 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/b85e9896c999255152fc6759a4caa8cd4713e3d3.camel%40kortschak.io.