Go language has many amazing features and syntax, such as how to swap the values of two variables.
package main
import "fmt"
func main() {
a := 5
b := 10
fmt.Println("Before swapping, values of a and b are:", a, b)
a, b = b, a
fmt.Println("After swapping, values of a and b are:", a, b)
}
Output:
Before swapping, values of a and b are: 5 10
After swapping, values of a and b are: 10 5
This interesting syntax feature is used to test whether an engineer has enough understanding of the Go language. But why is this way of exchanging values valid? How is this syntax feature implemented in Go?
The goal of this project is to answer a series of questions like this from the perspective of the underlying implementation in Go, by explaining the source code, including syntax, data structures, and a series of concurrency issues.
- How to Swap the Values of Two Variables
- Use New or Make
- String literals, Byte and Rune
- Struct, Interface, Pointer
- How to Use Defer
- Panic and Recover
- Gin
- Godep
- Array
- Stack
- Linked-List
- String
- Binary Tree
- Binary Search
- Graph
- Dynamic Programming
- Binary Search Tree
- Hash Table
- Binary
- Heap
- Trie
- Recursion
- Matrix
- Go Version Update
- What Are Golang Packages?
- Is Golang Case sensitive or Insensitive?
- Return Multiple Values From A Function in Go?
- Type Assertion in Go
- How Is GoPATH Different From GoROOT Variables In Go?
- In Go, Are There Any Good Error Handling Practices?
- Expressions. Diff b/w Curly Brackets and Square Brackets?