Code Monkey home page Code Monkey logo

simplebank's Introduction

simple bank

简介

simple bank 项目是用来学习 Go 后端开发流程所产生的

涉及到的工具及包

  1. db migration 数据库迁移工具,命令行形式安装 https://github.com/golang-migrate/migrate

  2. sqlc 根据 SQL 生成数据库读取代码

  3. gin 实现 RESTful API

  4. viper 读取配置

  5. testify 测试断言

  6. mock mock 测试 https://github.com/uber-go/mock

    命令 $mockgen -package mockdb -destination db/mock/store.go github.com/xiaowuzai/simplebank/db/sqlc Store

数据库迁移

创建迁移文件

$ migrate create -ext sql -dir db/migration -seq <migration_name>
/Users/zly/workspace/go/src/github.com/xiaowuzai/simplebank/db/migration/000001_init_schema.up.sql
/Users/zly/workspace/go/src/github.com/xiaowuzai/simplebank/db/migration/000001_init_schema.down.sql

执行迁移命令

migrate -path db/migration -database "postgresql://admin:123456@localhost:5432/simple_bank?sslmode=disable" -verbose up

注意

  1. 编写单元测试时,要保持用例相互独立,减少彼此的耦合

simplebank's People

Contributors

logoname avatar xiaowuzai 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.