kitex_gorm_gen

command module
v0.0.0-...-0bdcf1e Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

kitex_gorm

Introduce

A demo with Kitex and Gorm

  • Use thrift IDL to define RPC interface

  • Use kitex to generate code

  • Use Gorm/Gen and MySQL

  • /cmd generate gorm_gen

  • /dao initialize mysql connection

  • /model gorm generated user struct

  • /hander.go basic biz logic for updateUser, addUser, deleteUser, queryUser

IDL

This demo use thrift IDL to define RPC interface. The specific interface define in user.thrift

Code generation tool

This demo use kitex to generate code. The use of kitex refers to kitex

The kitex commands used can be found in Makefile

GORM/Gen

GEN: Friendly & Safer GORM powered by Code Generation.

This demo use GORM/Gen to operate MySQL and refers to Gen.

Quick Start
  • Update the Database DSN to your own in Database init file.
  • Refer to the code comments, write the configuration in Generate file.
  • Using the following command for code generation, you can generate structs from databases or basic type-safe DAO API for struct.
cd bizdemo/kitex_gorm_gen/cmd
go run generate.go

How to run

Run mysql docker
cd bizdemo/kitex_gorm_gen && docker-compose up
Run demo
cd bizdemo/kitex_gorm_gen
go build -o kitex_gorm_gen && ./kitex_gorm_gen

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
dao
kitex_gen
user/userservice
Code generated by Kitex v0.8.0.
Code generated by Kitex v0.8.0.

Jump to

Keyboard shortcuts

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