-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
33 lines (29 loc) · 1.29 KB
/
Copy pathmain.go
File metadata and controls
33 lines (29 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello, scala devs!")
// PointersExample()
// PointersPassByValueToCopy()
PointersPassByValueToCopyFail()
// TypeCompositionExample()
IfsAndLoopsExample()
// MapLoopExample()
// ErrorHandlingExample()
// DeferExample()
// ArrayIndexesExample()
}
// Lack of imutability - constants are compile-time constants, and only primitive types. Read https://go.dev/doc/effective_go#constants
// Pointers, pass by value, pass by reference
// Type system: structs, receiver functions, interfaces, avoid interface pointers
// No monads and collection API - back to `if` and `for` loops
// check `slices` and `maps` packages, as well as `container` for more advanced types (list/heap/ring)
// No options, nil dereference
// Error handling, handle all errors
// Defer statement
// Anti-framework philisofy - use libs, built in and third-party
// *Always read the docs:* for example `time.Now()` returns local time. Use time.Now().UTC() or .UnixMili() for writing to DB
// Project structure, internal packages, forbidden cyclical imports
// Concurrency: everything is blocking by default, use goroutines, channels, wait gruops, mutexes and others from `sync` package https://gobyexample.com/goroutines
// Fun fact: you can state index of element when creating array