Categorygithub.com/raj23manj/techshool-go
modulepackage
0.0.0-20240809025747-0b874e70bc7d
Repository: https://github.com/raj23manj/techshool-go.git
Documentation: pkg.go.dev

# README

Make file

Migration

  • migrate create -ext sql -dir db/migration -seq <name>
  • migrate -path db/migration -database "postgres://rajeshmanjunath:password@localhost:5432/simple_bank?sslmode=disable" -verbose up

DB pkg golang

ORM

  • SQLC

SQLC commands

* sqlc init

Initialise the project to avoid errors

  • go mod init
  • go mod tidy => to install dependencies

Testing and assertion frameworks:

  • gocheck
  • testify
  • gunit

Packages used in this app

Gin SQLX example:

Debugging with context name:

  • see section 1, 9

DB deadlocks:

  • if two accounts transactions are happening to and from and vice versa, it is always safe to excute the update statements in order
  • update account1 and account 2, so that the locks are taken on first sql and the other goroutine waits until it is done
  • see section, 10

Transaction levels in PSQL/MYSQL(11)

  • Read Uncommitted
  • Read Committed
  • Repeatable Read
  • Serializable (max)

Popular web frameworks

  • Gin, Beego, Echo, Revel, Martini, Fiber, Buffalo
  • Popular HTTP routers
    • FastHttp
    • Gorilla Mux
    • HttpRouter
    • chi

Mock DB for testing

  • Use Fake DB: Memory, implement a fake version of db & store data in memory, like map/hashmap
  • used stubbing, GOMOCK
  • using mockgen:
    • after installing, vi ~/.zshrc and add export PATH=$PATH:~/go/bin and source ~/.zshrc
  • mockgen -package mockDB -destination db/mock/store.go github.com/raj23manj/techshool-go/db/sqlc Store

Gvm

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author