Skip to content

Commit

Permalink
add common function convertTags.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenHanZhang committed Jan 8, 2024
1 parent 5c09452 commit 1748dff
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions alicloud/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -1647,3 +1647,18 @@ func MD5(b []byte) string {
ctx.Write(b)
return hex.EncodeToString(ctx.Sum(nil))
}

func ConvertTags(tagsMap map[string]interface{}) []map[string]interface{} {
tags := make([]map[string]interface{}, 0)
for key, value := range tagsMap {
if value != nil {
if v, ok := value.(string); ok {
tags = append(tags, map[string]interface{}{
"Key": key,
"Value": v,
})
}
}
}
return tags
}

0 comments on commit 1748dff

Please sign in to comment.