Go Markdown blogging system

Markdown blog system based on Go language

Technology stack

  • Front-end framework: Bootstrap
  • Language: the go
  • Network library: Standard library NET/HTTP
  • Configuration file parsing library Viper
  • Log library zap: github.com/uber-go/zap
  • Elasticsearch:github.com/olivere/ela…
  • Mysql:github.com/go-sql-driv…
  • Redis:github.com/go-redis/re…
  • File storage: Ali Cloud OSS and CDN
  • Markdown editor:github.com/pandao/edit…
  • Pprof performance tuning
  • Package management tool Go Modules
  • Background login: cookie
  • Use make to manage the Go project
  • Use shell(startup.sh) scripts to manage processes
  • Use YAML files for multi-environment configuration

The directory structure

├─ ├─ Makefile # ├─ Conf # ├─ ├─ Internal # ├─ Handler # HTTP # ├─ PKG # Internal Application code │ ├── Address and contact area. PLS contact area and contact area. PLS contact area and contact area. PLS contact area and contact area ├─ └─ exercises # ├─ startupCopy the code

Function module

The background

  • Article management: add, delete, change and check articles
  • Page management: add, delete, modify and check the page, and customize the Markdown page
  • Classification management: classification increase, deletion, change and check
  • Label management: Label list

The front desk

  • Article list: display articles in reverse order, can be placed at the top
  • Content page: Markdown content display
  • Tabbed pages: Sort by number of tabbed articles
  • About the page: Personal note
  • Reading list: Personal reading books
  • Site search: support article title, description, content, classification, tag fuzzy search

The development of specification

Follow: Uber Go language coding specification

Common commands

  • Make help View the help information
  • Make dep Download the Go dependency package
  • Make build Builds the project
  • Make tar package the file

Deployment process

  • Dependent environment:

    Mysql, Redis, ElasticSearch

    Elasticsearch can be enabled or disabled by configuration. Redis is designed for caching

  • Install the deployment

# 下载安装,可以不用是 GOPATH
git clone https://github.com/convee/goblog.git

# 进入到下载目录
cd goblog

# 生成环境配置文件
cd conf

# 修改 mysql、redis、elasticsearch 配置

# 导入初始化 sql 结构
mysql -u root -p
> create database blog;
> set names utf8mb4;
> use blog;
> source blog.sql;


# 下载依赖
make dep

# 编译
make build

# 运行
./goblog dev.yml

# 后台运行
nohup ./goblog dev.yml &
Copy the code
  • Supervisord deployment
[program:goblog]
directory = /data/modules/blog
command = /data/modules/blog/goblog -c conf/prod.yml
autostart = true
autorestart = true
startsecs = 5
user = root
redirect_stderr = true
stdout_logfile = /data/modules/blog/supervisor.log
Copy the code
  • Visit the home page

http://localhost:9091

  • Access to the background

http://localhost:9091/admin

User name: [email protected]

Password: 123456

  • Demonstration station: Convee.cn