module
0.0.0-20211004030449-7fbc5240b538
Repository: https://github.com/techmaster/golang.git
Documentation: pkg.go.dev
# README
Golang
Mô tả khoá học
Đây là khoá học đào tạo lập trình viên Golang xây dựng REST API trong hệ thống.
Đồ án mẫu là xây dựng một
Yêu cầu đầu vào
- Sinh viên cần sử dụng hệ điều hành Linux hoặc Mac để lập trình Golang
- Cần biết hoặc sẽ phải tự học Docker, Docker Compose, Docker Swarm
01. Cài đặt môi trường - công cụ và nhập môn
- Cài đặt Golang
- Sử dụng VSCode viết ứng dụng Golang đầu tiên
- In ra màn hình
- Tạo go module
- Khai báo biến: kiểu biến, gán, gán biến tự đoán kiểu
- Các kiểu căn bản. Ép kiểu
- Biến toàn cục vs cục bộ
- Khai báo hàm
- Hàm có nhiều tham số
- Hàm trả về nhiều giá trị, đặt tên biến trả về
- Hàm khác gì method
- Hàm variadic params
- Closure (anonymous function)
- Recursion
- Debug
Bài tập
- Tìm số nguyên tố
- Tính giai thừa
- In chuỗi fibonacci
02. Golang căn bản
- Public vs Private
- Module, tạo go module
- Con trỏ và lấy địa chỉ biến
- Composite Types: Array, Slice, Map, Struct
- Struct: khởi tạo, truyền vào hàm
- Array
- Slice và thao tác trên Slice
- Map và thao tác trên Map
Bài tập
- Phân tích dữ liệu trên file json
03. Interface - String
- Interfaces: khác biệt giữa Java và Golang
- Pointer Receiver vs Value Receiver
- Đọc file
- Các thao tác xử lý chuỗi: biến đổi, tìm kiếm, lấy một phần
Bài tập
- Đọc file đếm từ
- Mô phỏng
04. Thao tác file / folder
- Thao tác folder: thư mục hiện thời, di chuyển thư mục, tạo thư mục, xoá thư mục
- Thao tác file: tạo file, sửa tên file, copy file
- Quét file trong thư mục
Bài tập
Hãy sử dụng thư viện này https://github.com/xlab/treeprint và bài viết https://flaviocopes.com/go-list-files/ hãy in ra cấu trúc cây thư mục kiểu như sau:
.
├── config
│ └── config.go
├── controller
│ ├── ManufactureController.go
│ └── ProductController.go
05. Concurrency
- Go routine
- Go channel
06. Sync package
07. Unit Test (2 buổi)
- An Introduction to Testing in Go
- testify
- Improving Your Go Tests and Mocks With Testify
- gotests: gotests makes writing Go tests easy. It's a Golang commandline tool that generates table driven tests based on its target source files' function and method signatures. Any new dependencies in the test files are automatically imported.
- Benchmark Golang Code
08. Package phổ biến trong Go (2 buổi)
- Go cron định thời chạy tác vụ
- Uber Zap logging
- Viber configuration cấu hình
- Cobra
- Pterm
Bài tập thực hành
09. Resty Client
- HTTP Verbs: GET, POST, PUT, DELETE
- Status Code
- Header vs Body
- Retry
- Resty Client: Simple HTTP and REST client library for Go (inspired by Ruby rest-client)
- An introduction to REST API testing in Go with Resty
10. Fiber (3 buổi)
- Application
- Application Context
- Router - Routing - Group
- Middle ware
- Custom middle ware
11. Go Swagger (1 buổi)
12. GORM (2 buổi)
- Định nghĩa Model
- Quan hệ 1:nhiều, nhiều:nhiều
- Thêm sửa xoá truy vấn
- Transaction
13. JWT (1 buổi)
14. SOLID Pattern
- SOLID principle in GO
- SOLID Go Design
- SOLID : Interface Segregation Principle in Golang
- SOLID principles in Golang
- Design Patterns-Seven Design Principles for Golang
15. Design Patterns In Go (2 buổi)
- Creational Patterns
- Structural Patterns
- Behavioral Patterns
Reading List
https://github.com/ardanlabs/gotraining/tree/master/reading
Thread Safe Counting https://brunocalza.me/there-are-many-ways-to-safely-count/