toddler

package module
v0.0.0-...-ab8afbf Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: MIT Imports: 1 Imported by: 0

README

toddler-go

本项目用于 在使用Go开发项目时, 记录遇到的问题和解决方案, 记录相关技术的使用示例和简介, 记录遇到的优秀代码, 以及项目框架, 然后在后续开发中借鉴并使用之.

首要目的是记录, 其次才是以更好的格式记录. 谨记这点, 不可因噎废食.


结构上, 项目分为两部分, 源码和文档(docs/).

源码直接展示了项目结构, 以及使用示例. 方便自己或对Go比较熟悉, 有一定基础的人阅读查看.

文档则是按难易程度, 从入门讲起(目前还没有完善)

整体上, 项目是基于 微服务 风格的, 主张持续交付, 微服务化.

TODO

  1. 更改项目结构, 只对外开放rpc/http等服务, db层基础结构, 中间 ctrl/svc 逻辑对外隐藏.
  2. 新建docs, 放于项目最外层.
  3. service结构体+interface迁移到 internal 中.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckResult

type CheckResult struct {
	OK      bool   `gorm:"column:ok" json:"ok"`
	Limit   uint64 `gorm:"column:limit" json:"limit"`
	Message string `gorm:"column:message" json:"message"`
}

type DemoService

type DemoService interface {
	DoSomething(*Request) (*Response, error)
}

type DemoStruct

type DemoStruct struct {
	ID   int    `gorm:"column:id" json:"id"`
	Name string `gorm:"column:name" json:"name"`

	CreatedAt time.Time  `gorm:"column:created_at" json:"-"`
	UpdatedAt time.Time  `gorm:"column:updated_at" json:"-"`
	DeletedAt *time.Time `gorm:"column:deleted_at" json:"-"`
}

DemoStruct 结构体定义示例, gorm 会自动设置 CreatedAt/UpdatedAt/DeletedAt

func (DemoStruct) TableName

func (DemoStruct) TableName() string

TableName gorm 规范, 需要添加 TableName 以便gorm获取表名. 规范为 "业务名+s", 连字符模式. 如 user=> users.

type DemoStructDTO

type DemoStructDTO DemoStruct

DemoStructDTO 是 DemoStruct 对外展示的结构体, DemoStruct 即 DemoStructDO, 是数据库存储的结构体. 具体参考 link:/docs/namings[命名规范]

type Request

type Request struct {
	ID   int    `gorm:"column:id" json:"id"`
	Name string `gorm:"column:name" json:"name"`
}

type Response

type Response struct {
	OK  bool   `gorm:"column:ok" json:"ok"`
	Msg string `gorm:"column:msg" json:"msg"`
}

type RuleService

type RuleService interface {
	Check(params map[string]interface{}) (*CheckResult, error)
}

Directories

Path Synopsis
internal
cmd
tests/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
other-projects

Jump to

Keyboard shortcuts

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