【问题标题】:Gin-gonic Error : listen tcp: lookup addr on : no such hostGin-gonic 错误:监听 tcp:查找地址:没有这样的主机
【发布时间】:2020-06-17 16:46:30
【问题描述】:
Machine : Debian 10 running on Windows 10 - Hypervisor 
Go Ver  : go1.14.4
Gin-gonic Version : v1.6.3

运行程序时遇到错误!。尝试了很多在网上找到的解决方案但没有运气(那些与gin-gonic没有直接关系)

$ go run main.go
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] Listening and serving HTTP on addr:8080
[GIN-debug] [ERROR] listen tcp: lookup addr on 192.168.43.1:53: no such host
Calling okay!!!

main程序调用函数StartApplicatonapplication.go

    $ cat app/application.go
    package app

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

var (
        router = gin.Default()
)

//StartApplicaiton will call from main
func StartApplicaton() {
        mapUrls()
        router.Run("addr:8080")
        fmt.Println("Calling okay!!!")
}

包括/etc/resolve.conf/etc/hosts文件供参考

$cat /etc/resolv.conf
nameserver 192.168.43.1
nameserver 8.8.8.8


$ cat /etc/hosts
127.0.0.1       localhost
127.0.1.1       debian
192.168.43.1    wifirtr #addded to check

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

【问题讨论】:

    标签: go go-gin


    【解决方案1】:

    router.Run("addr:8080") 改为router.Run(":8081") 解决了我的问题!!, 仍然我不确定为什么它解决了我的问题(需要稍后挖掘)

    编辑:后来发现addr部分不在代码中,是IDE显示的帮助文本。我在学习在线教程时误解了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-30
      • 1970-01-01
      相关资源
      最近更新 更多