Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]Issue with the nacos registry in web.NewService() #63

Open
zhang-jianqiang opened this issue Apr 5, 2022 · 0 comments
Open

[BUG]Issue with the nacos registry in web.NewService() #63

zhang-jianqiang opened this issue Apr 5, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@zhang-jianqiang
Copy link

That reports an error when I use nacos registry in web.NewService():
panic: assignment to entry in nil map
My code:

package main

import (
	"user/config/config"
	"go-micro.dev/v4/web"
)

var (
	service = "go-layout"
	version = "latest"
)

func main() {
	srv := web.NewService(
		web.Name(service),
		web.Version(version),
		web.Registry(config.NewRegistry()),
		// web.Metadata(map[string]string{"version": version}),
	)
	srv.Run()
}
package config

import (
	"github.com/asim/go-micro/plugins/registry/nacos/v4"
	"github.com/nacos-group/nacos-sdk-go/v2/common/constant"
	"go-micro.dev/v4/registry"
)

func NewRegistry() registry.Registry {
	DefaultClientConfig := constant.ClientConfig{
		NamespaceId: "45d1be27-88ab-487d-b0ba-c09557fcaf29",
	}
	r := nacos.NewRegistry(
		nacos.WithClientConfig(DefaultClientConfig),
		nacos.WithAddress([]string{
			"127.0.0.1:8848",
		}))
	return r
}

go.mod

module user

go 1.18

require (
	github.com/asim/go-micro/plugins/registry/nacos/v4 v4.0.0-20220404185419-6dedee5d8c2c
	github.com/nacos-group/nacos-sdk-go/v2 v2.0.1
	go-micro.dev/v4 v4.2.1
)

Debug code,I find it will be ok to add web.Metadat option in web.NewService().

Environment:
Go Version: go version go1.18 windows/amd64

@xpunch xpunch added the bug Something isn't working label Apr 11, 2022
@xpunch xpunch transferred this issue from micro/go-micro Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants