- Chạy
docker-composer up
để tạo container - Chạy
go mod tidy
vàgo mod vendor
đểadd missing and remove unused modules
thêm vào go.mod file (thư viện sẽ đc tự thêm khi sử dụng trong code), chạygo mod vendor
đểmake vendored copy of dependencies
. Để sử dụng go mod cần enableexport GO111MODULE=on
. Để kiểm tra dùnggo env
(tất cả các lệnh này đều chạy trên docker). Sau khi sử dụng xong go mod, chạy lệnhexport GO111MODULE=off
để tắt go mod - Chạy
air -c .air.toml
để live-reload khi dev xem thêm tạihttps://github.com/cosmtrek/air
Tài liệu tham khảo
- Fasthttp:
https://github.com/valyala/fasthttp
sử dụng call api - Fiber:
https://docs.gofiber.io/
source core - Gorm:
https://gorm.io/docs/
truy vấn mysql orm - jsoniter:
https://github.com/json-iterator/go
parse json string - Go:
https://tour.golang.org/
base core - Air:
https://github.com/cosmtrek/air
hot reload khi dev code - MongoDB:
https://github.com/mongodb/mongo-go-driver
truy vấn mongodb - html engine:
https://curtisvermeeren.github.io/2017/09/14/Golang-Templates-Cheatsheet#actions
template engine html sử dụng
Testing & Benchmark:
- Go testing:
https://golang.org/pkg/testing/
- Để run test 1 API cụ thể:
go test -run GetOne
sẽ test funcTestGetOne
của fileuser_test.go
- Để test toàn bộ:
go test
- Để Benchmark toàn dự án:
go test -bench .
để benchmark 1 file testgo test -bench ten_file
VDgo test -bench User
- Để benchmark một func cụ thể:
go test -bench GetOne
sẽ tính điểm Benchmark của funcBenchmarkGetOne
của fileuser_test.go