forked from awslabs/goformation
/
naming.go
37 lines (24 loc) · 933 Bytes
/
naming.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
package main
import "strings"
// filename takes a resource or property name (e.g. AWS::CloudFront::Distribution.Restrictions)
// and returns an appropriate filename for the generated struct (e.g. aws-cloudfront-distribution_restrictions.go)
func filename(input string) string {
// Convert to lowercase
output := strings.ToLower(input)
// Replace :: with -
output = strings.Replace(output, "::", "-", -1)
// Replace . with _
output = strings.Replace(output, ".", "_", -1)
// Suffix with .go
output += ".go"
return output
}
// structName takes a resource or property name (e.g. AWS::CloudFront::Distribution.Restrictions)
// and returns an appropriate struct name for the generated struct (e.g. AWSCloudfrontDistributionRestrictions)
func structName(input string) string {
// Remove ::
output := strings.Replace(input, "::", "", -1)
// Remove .
output = strings.Replace(output, ".", "_", -1)
return output
}