gin框架安装
要安裝Gin包,首先需要安裝Go并設置Go工作區
1、下載并安裝
$?go?get?-u?github.com/gin-gonic/gin
2、在代碼中導入它
import?"github.com/gin-gonic/gin"
使用包管理工具Govendor安裝
1、go?get?govendor(安裝)
$?go?get?github.com/kardianos/govendor
2、創建項目文件夾并進入文件夾
$?mkdir?-p?$GOPATH/src/github.com/myusername/project?&&?cd?"$_"
3、初始化項目并添加?gin
$?govendor?init
$?govendor?fetch?github.com/gin-gonic/gin@v1.3
4、復制一個模板到你的項目
$?curl?https://raw.githubusercontent.com/gin-gonic/gin/master/examples/basic/main.go?>?main.go
5、運行項目
$?go?run?main.go
注意
使用gin需要Go的版本號為1.6或更高
總結
- 上一篇: 程序员笑话二十三
- 下一篇: gin使用 GET, POST, PUT