This is a creation in Article, where the information may have evolved or changed.
package main import "FMT" Type ifile interface {read () Write ()}type IReader interface {read ()}type file struct {}func (f *file) Read () {} func (F *file) write () {}func main () {f := new (File) var f1 ifile = f // ok because file implements all the methods in IFile VAR F2 IREADER = F1 // ok because IFile contains all the methods in Ireader// var f3 ifile = f2 // error because Ireader does not meet ifile (less one method)// var f3 ireader = new (File)// ok because file implements all the methods in Ireader// var f4 ifile = f3 // error because Ireader does not meet ifile ibid. How to solve it? to query the// interface query with an interface// this if statement checks if the object instance that the File1 interface points to implements the IFile interface// executes the specific code if// is implemented. NOTE: The emphasis here is on object instances, that is, the new (File)// file contains all the methods in IFile// so ok = trueif f5, ok := f3. (IFile); ok {fmt. Println (F5)}// asks the interface whether the object it points to is a type// The IF statement determines whether the object instance that the File1 interface points to is *file type// still Okif f6, ok := f3. (*file); ok {fmt. Println (f6)}fmt. Println (F1, F2, F3)}