Always use type that fit your needs, as this will optimize memory usage and lead to better performance
- Model,
- Repository (berhubungan dgn Db / Microservices),
- Service (Business Logic)
- Controller (isinya crud si gin)
go test ./... -v -coverprofile cover.out; go tool cover -html cover.out
-
WaitGroup purpose is to wait until goroutines finished executing before the program end
-
Mutex purpose is to ensure only one goroutine accesses data at a time. Basically, is to prevent changing data at the same time
-
Mutex.RLock & Mutex.RUnlock. if Mutex is currently locked by Mutex.Lock then Mutex.RLock will wait till its released. Basically, to prevent reading wrong data when Mutex.Lock working on changing some data
-
Channel should be closed if it's not being used, because it will cause memory leak
SELECT column_name, COUNT(*) FROM table_name WHERE condition GROUP BY column_name;
Example: SELECT major, COUNT(*) AS jumlah_peserta FROM mst_student WHERE major LIKE 'S%' GROUP BY major ;
Output:
ALTER TABLE table_name ADD CONSTRAINT constraint_name FOREIGN KEY(column_name) REFERENCES table_name_sec(column_name_sec)
Example: ALTER TABLE mst_product ADD CONSTRAINT fk_product_store FOREIGN KEY(store_id) REFERENCES mst_store(id)
-) Learn Database Normalization
https://youtu.be/GFQaEYEc8_8?si=-3F8fcKEYroFU9YE
https://youtu.be/UC_tJx4MBgk?si=Aa9aXHRZWpGfrgvZ