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

os/gtime: issue title polaris configuration center, only supports json data and does not support other file types (such as: yaml) #4104

Open
sharpleafage opened this issue Jan 8, 2025 · 2 comments
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@sharpleafage
Copy link

sharpleafage commented Jan 8, 2025

Go version

go.1.23

GoFrame version

gf >=2.8.0

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

dev

What did you see happen?

加载配置中心的问题,
gf >=2.8.0

func (c *Client) doUpdate(ctx context.Context) (err error) {
	if !c.client.HasContent() {
		return gerror.New("config file is empty")
	}
	var j *gjson.Json
	if j, err = gjson.DecodeToJson([]byte(c.client.GetContent())); err != nil {
		return gerror.Wrap(err, `parse config map item from polaris failed`)
	}
	c.value.Set(j)
	return nil
}

gf <2.8.0

func (c *Client) doUpdate(ctx context.Context) (err error) {
	if !c.client.HasContent() {
		return gerror.New("config file is empty")
	}
	var j *gjson.Json
	if j, err = gjson.LoadContent(c.client.GetContent()); err != nil {
		return gerror.Wrap(err, `parse config map item from polaris failed`)
	}
	c.value.Set(j)
	return nil
}


//bug
 gjson.DecodeToJson([]byte(c.client.GetContent())); 

What did you expect to see?

解决bug

@sharpleafage sharpleafage added the bug It is confirmed a bug, but don't worry, we'll handle it. label Jan 8, 2025
@Issues-translate-bot Issues-translate-bot changed the title os/gtime: issue title polaris 配置中心,只支持json数据,不支持其他文件类型(如:yaml) os/gtime: issue title polaris configuration center, only supports json data and does not support other file types (such as: yaml) Jan 8, 2025
@sharpleafage
Copy link
Author

按照文档 ,代码行不通, gf2.7版本,可以行的通
https://goframe.org/docs/micro-service/config-service

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


According to the documentation, the code does not work, but in gf2.7 version, it does.
https://goframe.org/docs/micro-service/config-service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.
Projects
None yet
Development

No branches or pull requests

2 participants