go错误汇总2:[ERROR] listen tcp: address 8082: missing port in address
-
错误信息:
[ERROR] listen tcp: address 8082: missing port in address
-
错误原因:
-
代码中端口的编写错误;
-
端口前面要加冒号
:
-
-
解决方案:
//导入gin包,_下划线是初始化就加载
import (
"github.com/gin-gonic/gin"
_ "github.com/gin-gonic/gin"
)
func main() {
//创建一个服务:gin.Default()
ginServer := gin.Default()
//访问地址,处理我们的请求,Request , Response
ginServer.GET("/hello", func(context *gin.Context) {
context.JSON(200, gin.H{"msg": "hello,world"})
})
//服务器端口
//错误:ginServer.Run("8082")
//端口前面要加冒号分割:
//正确:ginServer.Run(":8082")
}
标签:8082,missing,address,tcp,ERROR,gin,ginServer From: https://www.cnblogs.com/gzs1024/p/16883938.html