-
first-try: This folder includes some try of Golang
- Go is a pass-by-value language
- In Go, we have convention to put the test file in the same folder with the code (timestamp: 2022)
XXXX_test.go: use test suffix
go test -v -cover ./...
./...: run unit tests in all of tests
- golang-migrate
- To generate type-safe code from SQL: sqlc
go mod init <name with path>: init projectgo buildgo list -m all: 查看 dependencygo get: add the new dependencygo mod tidy: 自動刪除未使用的 dependencies
- Strong and statically typed
- Excellent communnity
- Simpicity
- Fast compile times
- Garbage collected: Do not need to focus on manage memory
- built-in testing support
- Object-oriented (but in it's own way)
- Go is a pass by value language
- Go makes "copies" of values when passed into functions
See
first-try/pass-by-value.go
| Non-Pointer Values | Pointer Wrapper Values |
|---|---|
| string | slice |
| int | map |
| float | function |
| boolean | |
| array | |
| struct |
At the moment just before Golang was created:
Python: Easy to use but slow (interpreted language)Java: Increasingly complex type systemC/C++: Complex type system and Slow compile times (E.g.C++applications written 10 years age still need to compile today)
go run <name of the file>
When your code imports packages contained in other modules, you manage those dependencies through your code's own module. That module is defined by a go.mod file that tracks the modules that provide those packages. That go.mod file stays with your code, including in your source code repositor
go mod init example.com/m
go run *.go
go build -o exec
import "github.com/xxxx/xxxxx"
- Learn Go Programming - Golang Tutorial for Beginners (2019.6)
- The Net Ninja; Go Tutorial (Golang) for Beginners (2021)
- Standard library
- Go 14年來的正與負
ps. 高效能 backend system 的很好導讀文