Installation Go gin framework of language

Try to install a little gin, some small problems to record what

installation steps

  1. First, let's look at the official documents, links point where
    you can see the installation procedure is very simple, just a word
go get -u github.com/gin-gonic/gin

Enter the phrase runs like waiting on the command line.

  1. The question is, since the issue of the wall, go get will be very slow, so the command line inside for a long time nothing happened, do not worry, it will slowly waiting to see gin-gonic / gin this directory appears
    Here Insert Picture Description
  2. This time the command line is still not over, still represents some stuff. Sometimes people may be impatient stopped (like me), then write a simple example to test whether the installation was successful
package main

import (
	"github.com/gin-gonic/gin"
)

func sayhello(c *gin.Context) {
	c.JSON(200, gin.H{
		"message": "hello go gin!",
	})

}

func main() {
	r := gin.Default()        //默认的路由引擎
	r.GET("/hello", sayhello) //get请求访问时执行sayhello
	//启动服务
	r.Run(":9090")
}

Run will prompt being given that the lack of yaml, locales ......

  1. The key to the place, because go get too slow, so I went to search for solutions that go mod + basic proxy settings, or change the hosts git clone, I try to look at git clone is the least expensive and effective, what is missing running time will be prompted to lack github / xxxx / xxxx, so long as the corresponding folder git clone down relevant documents like, yesterday forget because the screenshots so here we need to make up their own brain a little longer. I seem to remember git down is yaml, and then rename themselves yaml.v2, again try to run this example.
    Here Insert Picture Description
    Here Insert Picture Description
    Successful operation, a subsequent general environmental well start learning fun again.
Published 85 original articles · won praise 55 · views 20000 +

Guess you like

Origin blog.csdn.net/shelgi/article/details/103940413