Go Interfaces: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:


=Overview=
=Overview=


<font color=red>Interfaces are not types.</font>
<font color=red>Interfaces are not types.</font>
Line 13: Line 9:
<font color=red>Can only structs be interfaces, or there are other things that can be interfaces?</font>
<font color=red>Can only structs be interfaces, or there are other things that can be interfaces?</font>


=Declaration=


=Definition=
The interface declaration is introduced by the <tt>type</tt> keyword, to indicated that this is a user-defined type, followed by the type name and the keyword <tt>struct</tt>.


<pre>
<pre>

Revision as of 16:58, 30 March 2016

Internal

Overview

Interfaces are not types.

Can only structs be interfaces, or there are other things that can be interfaces?

Declaration

The interface declaration is introduced by the type keyword, to indicated that this is a user-defined type, followed by the type name and the keyword struct.

type MyInterface interface {
     functionName1() return_type
     functionName2() return_type
     ...
}