forked from aerospike/aerospike-management-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
singular_plural.go
71 lines (61 loc) · 2.3 KB
/
singular_plural.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package asconfig
// Maps singular array names to plurals
var singularToPlural = map[string]string{
"access-address": "access-addresses",
"address": "addresses",
"alternate-access-address": "alternate-access-addresses",
"datacenter": "datacenters",
"dc": "dcs",
"dc-int-ext-ipmap": "dc-int-ext-ipmap",
"dc-node-address-port": "dc-node-address-ports",
"device": "devices",
"file": "files",
"feature-key-file": "feature-key-files",
"mount": "mounts",
"http-url": "http-urls",
"ignore-bin": "ignore-bins",
"ignore-set": "ignore-sets",
"logging": "logging",
"mesh-seed-address-port": "mesh-seed-address-ports",
"multicast-group": "multicast-groups",
"namespace": "namespaces",
"node-address-port": "node-address-ports",
"report-data-op": "report-data-op",
"report-data-op-user": "report-data-op-user",
"report-data-op-role": "report-data-op-role",
"role-query-pattern": "role-query-patterns",
"set": "sets",
"ship-bin": "ship-bins",
"ship-set": "ship-sets",
"tls": "tls",
"tls-access-address": "tls-access-addresses",
"tls-address": "tls-addresses",
"tls-alternate-access-address": "tls-alternate-access-addresses",
"tls-mesh-seed-address-port": "tls-mesh-seed-address-ports",
"tls-node": "tls-nodes",
"xdr-remote-datacenter": "xdr-remote-datacenters",
"tls-authenticate-client": "tls-authenticate-client",
}
var pluralToSingular = map[string]string{}
func init() {
// Create the reverse mapping.
for k, v := range singularToPlural {
pluralToSingular[v] = k
}
}
// PluralOf returns the plural of the input noun.
func PluralOf(noun string) string {
plural, ok := singularToPlural[noun]
if !ok {
return noun
}
return plural
}
// SingularOf returns the singular of the input noun.
func SingularOf(noun string) string {
singular, ok := pluralToSingular[noun]
if !ok {
return noun
}
return singular
}