【发布时间】: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程序调用函数StartApplicaton在application.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
【问题讨论】: