forked from percolate/charlatan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.go
38 lines (29 loc) · 845 Bytes
/
map.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
package main
import "fmt"
// Map is the built-in map type
type Map struct {
keyType Type
subType Type
parameterFormat string
fieldFormat string
}
// ParameterFormat returns syntax for a parameter declaration
func (t *Map) ParameterFormat() string {
if t.parameterFormat != "" {
return t.parameterFormat
}
t.parameterFormat = fmt.Sprintf("map[%s]%s", t.keyType.ParameterFormat(), t.subType.ParameterFormat())
return t.parameterFormat
}
// ReferenceFormat returns the syntax for a reference
func (t *Map) ReferenceFormat() string {
return ""
}
// FieldFormat returns the syntax for a field declaration
func (t *Map) FieldFormat() string {
if t.fieldFormat != "" {
return t.fieldFormat
}
t.fieldFormat = fmt.Sprintf("map[%s]%s", t.keyType.FieldFormat(), t.subType.FieldFormat())
return t.fieldFormat
}