Git Product home page Git Product logo

golang's Introduction

Golang

Numerical Type Ranges

image
Always use type that fit your needs, as this will optimize memory usage and lead to better performance

Go Architecture Flow:

  1. Model,
  2. Repository (berhubungan dgn Db / Microservices),
  3. Service (Business Logic)
  4. Controller (isinya crud si gin)

Command to check coverage (Go Unit Testing)

go test ./... -v -coverprofile cover.out; go tool cover -html cover.out

Analogi Middleware di Gin Gonic

image

Golang Notes

  • 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

PostgreSQL

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:
image

Refer/Connect table to another table

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)

Using too much Join query will lead to bad query performance

USEFUL VIDEO'S

-) Learn Database Normalization
https://youtu.be/GFQaEYEc8_8?si=-3F8fcKEYroFU9YE
https://youtu.be/UC_tJx4MBgk?si=Aa9aXHRZWpGfrgvZ

golang's People

Contributors

damarwendha avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.