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.
go get github.com/go-spring/starter-gorm-mysql
Refer to the example.go file.
import _ "github.com/go-spring/starter-gorm-mysql"
Add gorm configuration in your project’s configuration file, for example:
spring.gorm.main.url=xxx
Refer to the example.go file.
import "gorm.io/gorm" type Service struct { DB *gorm.DB `autowire:""` }
Refer to the example.go file.
var version string err := s.DB.Raw("SELECT VERSION()").Scan(&version).Error
- Supports multiple gorm instances: You can define multiple gorm instances in the configuration file and reference them by name in your project.