搞一个自娱自乐的博客(一)准备工作

主要功能

1 发贴功能
2 帖子删除
3 帖子修改
4 帖子列表
5 板块列表
6 用户注册
7 用户列表

准备工作

选型

后台 iris
前端 golang template
数据库 mysql

环境安装

brew install go

开发工具

goland

版本

go version go1.15.2 darwin/amd64

初始化项目

mkdir myCommunity
cd myCommunity
go mod init myCommunity
go get github.com/kataras/iris/v12@master

此时 目录结构

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("

Welcome

") }) app.Listen(":8080") }

启动项目

Now listening on: http://localhost:8080
Application started. Press CMD+C to shut down.

浏览器访问 http://localhost:8080

image.png

你可能感兴趣的:(搞一个自娱自乐的博客(一)准备工作)