Original link: https://v3u.cn/a_id_231
Seeing the word interface, we will definitely think of interface-oriented programming. To put it bluntly, the interface specifies the specific behavior of the execution object, that is, the interface indicates what the execution object should do. Therefore, in a general sense, the interface is abstract, while the actual execution behavior is concrete. Definition of an interface In Golang, an interface is a set of method signatures, and a type is said to implement an interface when it provides definitions for all the methods in the interface. Very similar to the interface-oriented idea, the interface specifies the methods that the type should have, and the type determines how to implement these methods: /*Define the interface*/typeinterface_nameinterface{method_name1[return_type]method_name2[return_type]method_name3[…
This article is reprinted from: https://v3u.cn/a_id_231
This site is for inclusion only, and the copyright belongs to the original author.