gpt4 book ai didi

go - Gin 错误 : listen tcp: lookup addr on : no such host

转载 作者:行者123 更新时间:2023-12-01 21:13:09 29 4
gpt4 key购买 nike

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

最佳答案

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

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

enter image description here

关于go - Gin 错误 : listen tcp: lookup addr on : no such host,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62386450/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com