Skip to content

Commit 634b0b4

Browse files
author
pengjiang
committed
修复不可获取groupName的BUG
1 parent b2787e5 commit 634b0b4

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

target.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,30 @@ func parseURL(rawURL url.URL) (target, error) {
4646

4747
fmt.Print("rawURL.Query() <====")
4848

49+
// rawURL.Query()值为: map[groupName:[dev] namespaceid:[862309f6-ed95-49a4-87f1-d7fafdc03bae] timeout:[13000ms]]
50+
4951
params := make(map[string]interface{}, len(rawURL.Query()))
52+
var groupName string
5053
for name, value := range rawURL.Query() {
5154
params[name] = value[0]
5255
fmt.Print("name <====", name)
53-
fmt.Print("value <====", value)
56+
fmt.Print("value <====", value[0])
57+
if name == "groupname" {
58+
59+
groupName = value[0]
60+
fmt.Print("获取groupName value",groupName)
61+
62+
}
5463
}
5564

5665
err := mapping.UnmarshalKey(params, &tgt)
5766

67+
tgt.GroupName = groupName
5868

5969
if err != nil {
6070
return target{}, errors.Wrap(err, "Malformed URL parameters")
6171
}
6272

63-
if tgt.NamespaceID == "" {
64-
tgt.NamespaceID = "public"
65-
}
6673

6774
tgt.LogLevel = os.Getenv("NACOS_LOG_LEVEL")
6875
tgt.LogDir = os.Getenv("NACOS_LOG_DIR")

0 commit comments

Comments
 (0)