On Apr 27, 2018, at 11:56 PM, k1atti...@gmail.com wrote: > > I want to search in all library (which have source code) > Maybe i don't understand the concept of Golang (I have delphi,c++,c > background) > > > for exmaple : > I see this. This function need an interface type : r > func NewScanner(r io <https://golang.org/pkg/io/>.Reader > <https://golang.org/pkg/io/#Reader>) *Scanner > <https://golang.org/pkg/bufio/#Scanner> > > But which type satisfy this r parameter ?
I guess, for example, you want to use NewScanner but you don't know how to get an object whose type matches io.Reader? If so, even if you did an exhaustive search for all the types that match io.Reader, you will be no less confused. Instead what you can do is to follow your intuition. In this case you are most likely going to scan a file so look for a function like "os.Open", see its result type and if it has the necessary methods. For other examples, you can implement your own type that has the same methods. Unlike C++ you don't have to "inherit" from a base class. If you type implements the relevant functions, it can automatically be used. And your type can even match more than one interface if it implements methods specified by each of them. -- 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. For more options, visit https://groups.google.com/d/optout.