go注册中心Eureka,注册到线上和线下,都可以访问
本地通过127访问,
线上通过内网ip访问
package main
import (
"github.com/SimonWang00/goeureka"
"github.com/gin-gonic/gin"
"wbGo/controller"
"wbGo/task"
)
func main() {
//注册到 Eureka
registerToEureka()
registerToEureka2()
//下面是请求方法
router := gin.Default()
v1 := router.Group("/costing")
{
v1.POST("/select", controller.CostingSelect)
}
//调用定时任务
task.StartsTask()
router.Run("0.0.0.0:8000")
}
// 本地
func registerToEureka() {
// 实现注册到 Eureka 的逻辑,30秒一次心跳
//fmt.Println("注册到 Eureka")
opt := make(map[string]string)
goeureka.RegisterClient("http://127.0.0.1:6868", "", "myGoApp", "8000", "43", opt)
}
// 线上
func registerToEureka2() {
// 实现注册到 Eureka 的逻辑,30秒一次心跳
//fmt.Println("注册到 Eureka")
opt := make(map[string]string)
goeureka.RegisterClient("http://11.102.1.118:6868", "", "myGoApp", "8000", "43", opt)
}
标签:opt,string,到线,Eureka,注册,gin,goeureka
From: https://blog.csdn.net/qq_34631220/article/details/142380001