-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfact.go
More file actions
35 lines (25 loc) · 760 Bytes
/
Copy pathfact.go
File metadata and controls
35 lines (25 loc) · 760 Bytes
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
package requiredfield
import (
"strings"
"golang.org/x/tools/go/analysis"
)
// hasRequiredFields is a Fact attached to structs
// listing its required fields.
type hasRequiredFields struct {
// List is a list of field names
// in the struct that are marked required.
List []string
}
var _ analysis.Fact = (*hasRequiredFields)(nil)
func (*hasRequiredFields) AFact() {}
func (f *hasRequiredFields) String() string {
return "required<" + strings.Join(f.List, ", ") + ">"
}
// isRequiredField is a Fact attached to fields of anonymous structs
// that are marked required.
type isRequiredField struct{}
var _ analysis.Fact = (*isRequiredField)(nil)
func (*isRequiredField) AFact() {}
func (f *isRequiredField) String() string {
return "required"
}