久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      避坑啦!Gin安裝遇到的坑

      本文由go語言教程欄目給大家介紹,主題是關(guān)于Gin 安裝遇到的坑,希望對需要的朋友有所幫助!

      Gin 初始安裝

      1、安裝網(wǎng)官的文檔執(zhí)行
      go get -u github.com/gin-gonic/gin

      避坑啦!Gin安裝遇到的坑

      因不能翻墻,百度了說 用gopm 解決,群里的小伙伴說這種試早就過時了,現(xiàn)在都是用go mod 來解決
      于是 開啟go mod

      go env -w GOBIN=/Users/youdi/go/bin go env -w GO111MODULE=on go env -w GOPROXY=https://goproxy.cn,direct // 使用七牛云的

      使用go mod 來 管理一個新的項目

      mkdir Gone cd Gone go mod init Gone

      查看一下go.mod 文件

      module Gone  go 1.16

      go.mod文件一旦創(chuàng)建后,它的內(nèi)容將會被go toolchain全面掌控。go toolchain會在各類命令執(zhí)行時,比如go get、go build、go mod等修改和維護go.mod文件。

      go.mod 提供了module, require、replace和exclude 四個命令

      • module 語句指定包的名字(路徑)
      • require 語句指定的依賴項模塊
      • replace 語句可以替換依賴項模塊
      • exclude 語句可以忽略依賴項模塊
      package mainimport (     "github.com/gin-gonic/gin")func main() {     r := gin.Default()     r.GET("/ping", func(c *gin.Context) {         c.JSON(200, gin.H{             "message": "pong",         })     })     r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")}

      執(zhí)行 go run main.go 運行代碼會發(fā)現(xiàn) go mod 會自動查找依賴自動下載
      結(jié)果報錯

      main.go:3:8: no required module provides package github.com/gin-gonic/gin; to add it:         go get github.com/gin-gonic/gin

      執(zhí)行:go mod edit -require github.com/gin-gonic/gin@latest 解決,指定Gin的版本
      再次運行 go run main.go 報錯

      go: github.com/gin-gonic/gin@v1.7.4: missing go.sum entry; to add it:         go mod download github.com/gin-gonic/gin

      然后執(zhí)行 go mod tidy 再次執(zhí)行 go run main.go 終于跑起來了

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號