test golang Flashcards
method
<p>function w/ a receiver as an extra parameter</p>
method declaration
<p>func RECIEVER NAME SIGNATURE {<br></br>STMT+<br></br>}</p>
method declaration
<ul><li>Likely should use method declaration (syntax) w/ pointer receivers b/c Can modify the receiver pointed to, efficiency</li><li>In method "gracefully" handle nil reciever</li></ul>
receiver
<p>(VARDECL)</p>
method expression
<p>RECIEVER.METHOD</p>
interfaces in Tour
<p></p>
append
<p>Always use return value b/c May create new slice in the process</p>
array/slice
<ol><li>(Optional) Either<ul><li>array declaration (syntax)</li><li>Implicit declare</li></ul></li><li>(Optional) Initialize w/ either<ul><li>Specify array literal</li><li>make (syntax)</li></ul></li><li>Until done do any<ul><li>Slice expression (syntax)</li><li>Indexing expression (syntax)</li><li>append (user)</li></ul></li></ol>
<p></p>
interface
<p>method set of an interface type</p>
method set
<p>For some type T, is all methods declared w/ receiver type T</p>
implement the interface
<p>A type T implements an interface I if and only if T has a method set that is a superset of I</p>
interface type
<p>Set of method signatures w/ variables of the type containing any value that implements the interface</p>
interface type
<p>interface {<br></br>(METHODSPEC;|IFNAME;)+<br></br>}</p>
interface type
<ol><li>If interface value has not been assigned a concrete type then invalid memory address run-time panic b/c Unable to determine which concrete method to call</li><li>Else if assigned a concrete type but underlying value is nil then a method call is conducted w/ nil receiver</li><li>Else method call w/ non-nil reciever</li></ol>
interface type declaration
<p>type NAME INTERFACETYPE</p>