If you are not using an IDE, you can always use, for example, "go doc os.Open" to see what os.Open returns.
For user packages, you can use for example "go doc github.com/benhoyt/goawk/parser.ParseProgram" from your directory that contains "go.mod" for your program. > On Apr 22, 2023, at 3:31 PM, jlfo...@berkeley.edu <jlforr...@berkeley.edu> > wrote: > > import “os” > func main() { > file, _ := os.Open(os.Args[1]) > myfunc(file) > } > > func myfunc(file ???) { > } > > 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. > > But, it doesn’t matter how experienced I am with Go when I start using > user-defined types from packages that aren’t in the Go standard library. For > example (from Ben Hoyt’s excellent goawk program): > > import "github.com/benhoyt/goawk/parser > <http://github.com/benhoyt/goawk/parser>" > func main() { > prog, err := parser.ParseProgram(fileReader.Source(), parserConfig) > myfunc(prog) > } > > func myfunc(prog ???) { > } > -- 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/B6FBE67E-22AA-4D85-8B7E-032B722CE21D%40iitbombay.org.