This is a creation in Article, where the information may have evolved or changed.
In the Go language, interface fades the symbolic meaning of interface in object-oriented, and the interface in go language is merely the abstract concept of the same kind of things as "expression form". In the go language, as long as the "type" with the same "expression" has the same interface, it does not need to consider the practical significance of this interface in the specific use. In this way, the cost of interface is given to the user, not to the designer.
The designer is only responsible for the design method, that is, the constituent elements of interface, interface in the specific use of the actual meaning should be given to interface users to determine. To give the simplest example:
Running hypothesis has two meanings: one is escape, English is escape, the other is running, English is called run. If Chinese is a kind, call him pao.
Type Badman struct{}func (Badman *badman) Pao () {}type Sportman struct{}func (sportman *sportman) Pao () {}//Designers only consider this part of type Pao interface{ Pao ()}//This section is considered by the user var Paoa Pao = new (Badman) var paob Pao = new (Sportman)
Although the two types of Pao interfaces actually have different meanings, for the go language, I think their interfaces are the same, because the "form of expression" is the same. As for what scenario should go to use Badman or Sportman Pao interface in order to complete the task correctly, this is the user consideration, design interface people do not consider.
Go's interface is closer to the essence of the concept of interface, because it can be grouped into this interface population for the type of any method that implements the interface type. In object-oriented design language, type must be safe to implement interface content to be managed by it, otherwise it is an abstract class. The type of the object of birth is still a cloth.
On the path of abstraction and instantiation, the go language one step, and if Java and CPP want to one step, then it is necessary to implement all interface methods.