基於go+vue實現的golang每日新聞資料瀏覽與檢索平臺

mikemintang發表於2018-01-09

介紹

gonews是基於go+vue實現的golang每日新聞瀏覽與檢索平臺

專案截圖

gonews

部署

  • 獲取新聞資料
git clone https://github.com/gocn/news /data/news
複製程式碼
  • 獲取原始碼
go get -u github.com/mikemintang/gonews
複製程式碼
  • 解析資料
nohup gonews -d /data/news > /data/log/gonews.log 2>&1 
複製程式碼
  • 啟動Api
nohup gonews -a api -p 8017 > /data/log/gonews.log 2>&1 &
複製程式碼
  • 前端部署
cd $GOPATH/src/github.com/mikemintang/gonews/web
npm install
npm run build
複製程式碼
  • Nginx配置
server {
    listen       80;
    server_name gonews.idoubi.cc;
    index index.html index.htm index.php;
    root  /data/go/src/mikemintang/gonews/web;

    location /api {
        rewrite         ^.+api/?(.*)$ /$1 break;
        proxy_pass      http://127.0.0.1:8017;
    }
}
複製程式碼
  • Shell指令碼
#!/bin/sh

cd /data/news
git pull origin master
nohup gonews -d /data/news/ > /data/log/gonews.log 2>&1
複製程式碼
  • 定時任務
crontab -e
*/10 * * * * /bin/sh /data/shell/cache_news.sh
複製程式碼

用到的技術

golang包

  • github.com/go-redis/redis
  • encoding/json
  • flag
  • net/http
  • net/url
  • strconv
  • sync
  • crypto/md5
  • fmt
  • io
  • io/ioutil
  • net/url
  • os
  • path/filepath
  • regexp
  • strconv
  • strings
  • time

npm包

  • vue
  • vuex
  • vue-router
  • axios
  • moment
  • mockjs

歡迎提交Pull Request

相關文章