主要功能
1 發(fā)貼功能
2 帖子刪除
3 帖子修改
4 帖子列表
5 板塊列表
6 用戶注冊
7 用戶列表
準備工作
選型
后臺 iris
前端 golang template
數(shù)據(jù)庫 mysql
環(huán)境安裝
brew install go
開發(fā)工具
goland
版本
go version go1.15.2 darwin/amd64
初始化項目
mkdir myCommunity
cd myCommunity
go mod init myCommunity
go get github.com/kataras/iris/v12@master
此時 目錄結(jié)構(gòu)
myCommunity
- go.mod
main.go
Hello world!
增加一個主入口main.go
package main
import "fmt"
func main() {
fmt.Print("Hello world!")
}
右鍵啟動
hello world!
Process finished with the exit code 0
將main.go 改造成web入口
package main
import (
"github.com/kataras/iris/v12"
)
func main() {
app := iris.New()
// GET方法 返回一個 Welcome
app.Handle("GET", "/", func(ctx iris.Context) {
ctx.HTML("<h1>Welcome</h1>")
})
app.Listen(":8080")
}
啟動項目
Now listening on: http://localhost:8080
Application started. Press CMD+C to shut down.
瀏覽器訪問 http://localhost:8080

image.png