admin管理员组

文章数量:1558098

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

本文标签: DomesticAgentsetGolangbeego