iris学习笔记

iris后端开发笔记整理

Main

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package main

import (
"main/router_Controller"

"github.com/kataras/iris/v12"
)

func main() {
// Get context
app := iris.Default()

// Integrate router into one controller
router_Controller.Hub(app)

// Listens and serves incoming http requests
// on http://localhost:8080.
app.Listen(":8988")
}

Database connection

We use XORM to connect database.

Install

1
2
3
4
5
6
7
# install driver for mysqsl
go get -u github.com/go-sql-driver/mysql

#
go get xorm.io/xorm # install xorm
go get xorm.io/builder # install builder
go get xorm.io/reverse # install reverse tool, this can help you generate code automatically accroding to the database we already have.

Config

Log