Skip to content

go-spring/starter-gorm-mysql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

starter-gorm-mysql

English | 中文

The project has been officially released, welcome to use!

starter-gorm-mysql provides a mysql client wrapper based on gorm, making it easy to integrate and use mysql in Go-Spring applications.

Installation

go get github.com/go-spring/starter-gorm-mysql

Quick Start

1. Import the starter-gorm-mysql Package

Refer to the example.go file.

import _ "github.com/go-spring/starter-gorm-mysql"

2. Configure the gorm Instance

Add gorm configuration in your project’s configuration file, for example:

spring.gorm.main.url=xxx

3. Inject the gorm Instance

Refer to the example.go file.

import "gorm.io/gorm" type Service struct { DB *gorm.DB `autowire:""` }

4. Use the gorm Instance

Refer to the example.go file.

var version string err := s.DB.Raw("SELECT VERSION()").Scan(&version).Error

Advanced Features

  • Supports multiple gorm instances: You can define multiple gorm instances in the configuration file and reference them by name in your project.

About

🔥 [released] gorm mysql 启动器 (starter for gorm mysql)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages