Go Day 1: Fundamentals — Part 1
Though I used golang in the past for development, it is been a while since I actively used it. At present, I see the need to revamp my skills and get myself to revisit golang. So from here on, I will be focusing on GoLang. Learning RUST is paused for a while. Let's start by understanding a few semantics.
Function Naming
Sprintf()
Note: We use under scroll in multi-word variable names.
Exported Names & Function Declaration
Error Handling
init()
Rand & Time API
append(slice, new_element)
One thing I liked about golang is that we have global function names like len()
, append()
, etc which can be used on all the data structures (correct me if I am wrong). In this way, it is a more Function oriented (like len()
in one package, ie it is saved in builtin.go
) grouping rather than DataStucture( All String-related functions in one class like String.java
) oriented grouping.
There is no Function OverLoading
Go does not support function overloading.
range slice
range iterates over elements in a variety of data structures.
Testing a Package
- Here we are appending
_test.go
to the file name. - We have the
same package name
definition on the top of the test file. - When we have
“”
inside a string, we use theGRAVE ACCENT
(`) symbol
- we use
testing.T
to print the error message.
Conclusion
We will stop here now. In the following days, we will try covering the fundamentals in separate threads.