Skip to content

go-spring/starter-gorm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

starter-gorm

English

[仅发布] 该项目仅为最终发布,不要向该项目直接提交代码,开发请关注 go-spring 项目。

Installation

Prerequisites

  • Go >= 1.12

Using go get

go get github.com/go-spring/[email protected] 

Quick Start

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

main.go

package main

import (
	"fmt"

	"github.com/go-spring/spring-base/log"
	"github.com/go-spring/spring-core/gs"
	"gorm.io/gorm"

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

type runner struct {
	DB *gorm.DB `autowire:""`
}

func (r *runner) Run(ctx gs.Context) {
	var engines []string
	r.DB.Raw("select engine from engines").Scan(&engines)
	log.Infof("got mysql engines %v", engines)
	go gs.ShutDown()
}

func main() {
	gs.Object(&runner{}).Export((*gs.AppRunner)(nil))
	fmt.Printf("program exited %v\n", gs.Web(false).Run())
}

application.properties

db.url=root:@/information_schema?charset=utf8&parseTime=True&loc=Local

Customization

About

「仅发布」gorm 启动器 ( starter for gorm )

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages