You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by li...@apache.org on 2024/05/27 10:43:54 UTC

(incubator-answer) 02/02: fix(conf): set default config in ui

This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git

commit d7a26952acbf961d3d15ff20efc098ccb5c6f97e
Author: LinkinStars <li...@foxmail.com>
AuthorDate: Mon May 27 18:43:42 2024 +0800

    fix(conf): set default config in ui
---
 internal/base/conf/conf.go | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/internal/base/conf/conf.go b/internal/base/conf/conf.go
index 17090d4b..67e02340 100644
--- a/internal/base/conf/conf.go
+++ b/internal/base/conf/conf.go
@@ -60,6 +60,13 @@ type Data struct {
 	Cache    *data.CacheConf `json:"cache" mapstructure:"cache" yaml:"cache"`
 }
 
+// SetDefault set default config
+func (c *AllConfig) SetDefault() {
+	if c.UI == nil {
+		c.UI = &server.UI{}
+	}
+}
+
 // ReadConfig read config
 func ReadConfig(configFilePath string) (c *AllConfig, err error) {
 	if len(configFilePath) == 0 {
@@ -73,6 +80,7 @@ func ReadConfig(configFilePath string) (c *AllConfig, err error) {
 	if err = config.Parse(&c); err != nil {
 		return nil, err
 	}
+	c.SetDefault()
 	return c, nil
 }