Go Day 1: Fundamentals — Part 1

Arjun Sunil Kumar
Go Rust
Published in
3 min readJun 4, 2022

--

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

https://stackoverflow.com/a/38617771/1609570
https://go.dev/doc/effective_go#mixed-caps

Sprintf()

https://www.educative.io/edpresso/whats-is-the-sprintf-function-in-golang
https://www.educative.io/edpresso/whats-is-the-sprintf-function-in-golang
https://www.educative.io/edpresso/whats-is-the-sprintf-function-in-golang

Note: We use under scroll in multi-word variable names.

Exported Names & Function Declaration

https://go.dev/doc/tutorial/create-module

Error Handling

https://go.dev/doc/tutorial/handle-errors

init()

https://stackoverflow.com/a/64189555/1609570
https://stackoverflow.com/a/46505171/1609570
https://stackoverflow.com/a/49831018/1609570
https://stackoverflow.com/a/49831018/1609570

Rand & Time API

https://go.dev/doc/tutorial/random-greeting

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.

https://pkg.go.dev/builtin#append

There is no Function OverLoading

Go does not support function overloading.

https://stackoverflow.com/a/71099156/1609570
https://stackoverflow.com/a/6987002/1609570

range slice

range iterates over elements in a variety of data structures.

https://gobyexample.com/range

Testing a Package

https://go.dev/doc/tutorial/add-a-test
  • 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 the
    GRAVE 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.

--

--

Arjun Sunil Kumar
Go Rust

Writes on Database Kernel, Distributed Systems, Cloud Technology, Data Engineering & SDE Paradigm. github.com/arjunsk