Go Functions: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 16: Line 16:


Built-in functions are available by default, without importing any package. Their names are [[Go_Language#Pre-Declared_Functions|predeclared function identifiers]]. They give access to Go's internal data structures. Their semantics depends on the arguments.
Built-in functions are available by default, without importing any package. Their names are [[Go_Language#Pre-Declared_Functions|predeclared function identifiers]]. They give access to Go's internal data structures. Their semantics depends on the arguments.
:::{|class="wikitable" style="text-align: left;"
| <font face='menlo' size='-2'>[[Go Slices#append.28.29|append]]</font> || <font face='menlo' size='-2'>[[#cap.28.29|cap()]]</font> ||  <font face='menlo' size='-2'>[[Go Built-In Function close|close]]</font>  || <font face='menlo' size='-2'>[[Go Built-In Functions for Manipulating Complex Numbers#complex.28.29|complex]]</font> || <font face='menlo' size='-2'>[[Go Slices#copy.28.29|copy]]</font>
|-
| <font face='menlo' size='-2'> [[Go Maps#delete.28.29|delete]]</font> || <font face='menlo' size='-2'> [[Go Built-In Functions for Manipulating Complex Numbers#imag.28.29|imag]]</font> || <font face='menlo' size='-2'> [[#len.28.29|len()]]</font> || <font face='menlo' size='-2'> [[Go Built-In Function make|make()]]</font> || <font face='menlo' size='-2'> [[Go Built-In Function new|new]]</font>
|-
| <font face='menlo' size='-2'> [[Go Concepts - Error Handling#Panics|panic]]</font> || <font face='menlo' size='-2'> [[Go_Printing_to_Stdout_and_Stderr#print.28.29|print]]</font> || <font face='menlo' size='-2'>[[Go_Printing_to_Stdout_and_Stderr#println.28.29|println]]</font> || <font face='menlo' size='-2'> [[Go Built-In Functions for Manipulating Complex Numbers#real.28.29|real]]</font> || <font face='menlo' size='-2'> [[Go Concepts - Error Handling#Panics|recover]]</font>
|-
|}


==Length and Capacity==
==Length and Capacity==

Revision as of 20:39, 24 August 2023

External

Internal

Overview

Go functions allow variables to be declared, inside the function, with the short variable declaration.

Pass by Value vs. Pass by Reference

Arrays are passed by value.

Built-in Functions

Built-in functions are available by default, without importing any package. Their names are predeclared function identifiers. They give access to Go's internal data structures. Their semantics depends on the arguments.

append cap() close complex copy
delete imag len() make() new
panic print println real recover

Length and Capacity

https://golang.org/ref/spec#Length_and_capacity

len()

len() returns string length, array length, slice length and map size.

cap()

cap() returns slice capacity.

Complex Number Manipulation

complex() real() imag()

TO DO: Continue to Distribute These Built-in Functions

close()

Allocation: new()

Making slices, maps and channels: make()

Appending to and copying slices: append(), copy()

Deletion of map elements delete()

Handling panics panic(), recover()

DEPLETE THIS


Built-in functions for type conversions.

deplete this Go Concepts - Functions