123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package legacy
- import (
- "strings"
- )
- func GetMapWithoutPrefix(set map[string]string, prefix string) map[string]string {
- m := make(map[string]string)
- for key, value := range set {
- if strings.HasPrefix(key, prefix) {
- m[strings.TrimPrefix(key, prefix)] = value
- }
- }
- if len(m) == 0 {
- return nil
- }
- return m
- }
- func GetMapByPrefix(set map[string]string, prefix string) map[string]string {
- m := make(map[string]string)
- for key, value := range set {
- if strings.HasPrefix(key, prefix) {
- m[key] = value
- }
- }
- if len(m) == 0 {
- return nil
- }
- return m
- }
|