https://github.com/go-spring/starter-gorm-mysql
starter for gorm with mysql
https://github.com/go-spring/starter-gorm-mysql
go-spring gorm mysql
Last synced: 8 months ago
JSON representation
starter for gorm with mysql
- Host: GitHub
- URL: https://github.com/go-spring/starter-gorm-mysql
- Owner: go-spring
- License: apache-2.0
- Created: 2020-10-10T14:12:49.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-09-05T14:01:07.000Z (9 months ago)
- Last Synced: 2025-09-22T01:36:00.685Z (9 months ago)
- Topics: go-spring, gorm, mysql
- Language: Go
- Homepage:
- Size: 385 KB
- Stars: 2
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# starter-gorm-mysql
[English](README.md) | [中文](README_CN.md)
> 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
```bash
go get github.com/go-spring/starter-gorm-mysql
```
## Quick Start
### 1. Import the `starter-gorm-mysql` Package
Refer to the [example.go](example/example.go) file.
```go
import _ "github.com/go-spring/starter-gorm-mysql"
```
### 2. Configure the gorm Instance
Add gorm configuration in your project’s [configuration file](example/conf/app.properties), for example:
```properties
spring.gorm.main.url=xxx
```
### 3. Inject the gorm Instance
Refer to the [example.go](example/example.go) file.
```go
import "gorm.io/gorm"
type Service struct {
DB *gorm.DB `autowire:""`
}
```
### 4. Use the gorm Instance
Refer to the [example.go](example/example.go) file.
```go
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.