You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2022/10/26 11:02:20 UTC

[dubbo-go] 05/07: move constant

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

alexstocks pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git

commit 619692ca8b6291df656858e29da7ff8d168ad60e
Author: zlb <10...@qq.com>
AuthorDate: Mon Aug 15 22:55:08 2022 +0800

    move constant
---
 common/constant/file/suffix.go | 5 +++++
 config/config_resolver.go      | 9 ++-------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/common/constant/file/suffix.go b/common/constant/file/suffix.go
index bd8876c57..fe1b41ebb 100644
--- a/common/constant/file/suffix.go
+++ b/common/constant/file/suffix.go
@@ -26,3 +26,8 @@ const (
 	YML        = Suffix("yml")
 	PROPERTIES = Suffix("properties")
 )
+
+const (
+	PlaceholderPrefix = "${"
+	PlaceholderSuffix = "}"
+)
diff --git a/config/config_resolver.go b/config/config_resolver.go
index 048bb7819..517a41984 100644
--- a/config/config_resolver.go
+++ b/config/config_resolver.go
@@ -76,11 +76,6 @@ func GetConfigResolver(conf *loaderConf) *koanf.Koanf {
 	return resolvePlaceholder(k)
 }
 
-const (
-	PlaceholderPrefix = "${"
-	PlaceholderSuffix = "}"
-)
-
 // resolvePlaceholder replace ${xx} with real value
 func resolvePlaceholder(resolver *koanf.Koanf) *koanf.Koanf {
 	m := make(map[string]interface{})
@@ -107,10 +102,10 @@ func resolvePlaceholder(resolver *koanf.Koanf) *koanf.Koanf {
 
 func checkPlaceholder(s string) (newKey, defaultValue string) {
 	s = strings.TrimSpace(s)
-	if !strings.HasPrefix(s, PlaceholderPrefix) || !strings.HasSuffix(s, PlaceholderSuffix) {
+	if !strings.HasPrefix(s, file.PlaceholderPrefix) || !strings.HasSuffix(s, file.PlaceholderSuffix) {
 		return
 	}
-	s = s[len(PlaceholderPrefix) : len(s)-len(PlaceholderSuffix)]
+	s = s[len(file.PlaceholderPrefix) : len(s)-len(file.PlaceholderSuffix)]
 	indexColon := strings.Index(s, ":")
 	if indexColon == -1 {
 		newKey = strings.TrimSpace(s)