Download the last release from: https://golang.org/dl/
Or use a language distribution versioning tool: https://github.com/asdf-vm/asdf
go get -u golang.org/x/tools/...
package account
func myFunc() {
return "Hello, world!"
}
bool
string
int int8 int16 int32 int64
uint uint8 uint16 uint32 uint64 uintptr
byte // alias for uint8
rune // alias for int32
// represents a Unicode code point
float32 float64
complex64 complex128
You can see more details:
fmt.Printf("Type: %T Value: %v\n", x, x)
Create a file ending with _test.go
, like this:
touch account_test.go
Now, let's write some tests.
package account
import "testing"
func TestAbc(t *testing.T) {}
t.Error() // to indicate test failed
}
type Account struct {
ID int64
PersonName string
Cards []*Card
}
type Logger interface {
String() string
Print(interface{})
}
- Goroutines
- Wait Groups
- Mutexes
Real world projects ideas:
- A CLI that automates a process done by the development team.
- A Rest API that gets the weather for my location.
- A memory cache system, Redis alike.