GinModule

command module
v0.0.0-...-da13f83 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2024 License: MIT Imports: 7 Imported by: 0

README

GinModule

SimpleBank Based on https://github.com/techschool/simplebank

Docker Setting

https://hub.docker.com/_/postgres

  1. get image: docker pull {image}:{tag}

docker pull postgres:12-alpine 2. start a container: docker run --name {container_name} -e {environment_variable} -p {host_ports:container_ports} -d {image}:{tag} docker run --name postgres12 -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=root -d postgres:12-alpine 3. connect to container: docker exec -it {container_name_or_id} {command} [args] docker exec -it postgres12 /bin/sh
docker exec -it postgres12 psql -U root

docker compose

https://docs.docker.com/compose/gettingstarted/

database

ACID Property

Atomicity
Consistency
Isolation
Durability

CURD

database/sql: fast but mistakes cannot be caught until runtime
gorm: low code but slow on high load (gorm的运行速度比标准库慢3-5倍)
sqlx: fast & easy but mistakes cannot be caught until runtime
sqlc: automatic code generation, especially for Postgres

Isolation Level 事务隔离级别

In Mysql:
select @@transaction_isolation
set session transaction isolation level {isolation_level}

In Postgres:
show transaction isolation level;
// only can set transaction level within trasaction
set transaction isolation level {isolation level}

isolation level:

  • read uncommitted
  • read committed: stop dirty read
  • repeatable read(Mysql default): stop dirty read and unrepeatable read
  • serializable: stop dirty read, unrepeated read and serialization anomaly(序列化异常)

In Postgres

  • read uncommitted mode behaves like read committed.
  • Using dependence detection
  • default level: RC

In Mysql

  • default level: RR
  • Using locking mechanism

Github Workflow

  1. Actions on the website
  2. Coding .yml file to decide steps

gomock

  1. install: https://github.com/golang/mock
  2. vi ~/.zshrc
  3. add export PATH=$PATH:~/go/bin
  4. source ~/.zshrc
  5. using which mockgen to make sure mockgen is valid.

hash password

{ALG}{Cost}{Salt}{Hash}
e.g. $2a$10$dGIJ4fEL7jKAzzddDuwGSe3o9mTcO/Tv.3XwJsbJZHXOhXrjr01ce

password -- bcrypt hash (cost, salt) --> hashed_password

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
db
mock
Package mockdb is a generated GoMock package.
Package mockdb is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL