admin管理员组

文章数量:1559094

install the gin framework

go get -u github/gin-gonic/gin

resolve golang prompt dial tcp 172.217.160.113:443: connectex: a connection attempt failed:

go get: module github/rogpeppe/godef: get "https://proxy.golang/github/rogpeppe/godef/@v/list": dial tcp 172.217.160.113:443: connectex: a connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

solution: change it to our domestic available agent address

go env -w goproxy=https://goproxy
​

#create file hellodemo.go 

package main
import (
  "net/http"
  "github/gin-gonic/gin"
)
func main() {
  r := gin.default()
  r.get("/hello", func(c *gin.context) {
    c.json(http.statusok, gin.h{
      "message": "helloworld",
    })
  })
  r.run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}

 run hellodemo.go and visit 0.0.0.0:8080/hello ("localhost:8080/hello")

go run hellodemo.go

insatll the beego framework

go get github/beego/beego/v2@latest
package main
import "github/beego/beego/v2/server/web"
func main() {
	web.run()
}

build and run

go build hello.go
./hello

本文标签: domestic