Skip to content

Commit 79c72e6

Browse files
committed
Add const for source type name
Signed-off-by: Brian Goff <[email protected]>
1 parent 80c5f7e commit 79c72e6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cmd/gen-source-variants/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ func extractSourceFields() ([]SourceField, error) {
7070
break
7171
}
7272

73+
const sourceTypeRef = "Source"
7374
ast.Inspect(node, func(n ast.Node) bool {
74-
if ts, ok := n.(*ast.TypeSpec); ok && ts.Name.Name == "Source" {
75+
if ts, ok := n.(*ast.TypeSpec); ok && ts.Name.Name == sourceTypeRef {
7576
found = true
7677
if st, ok := ts.Type.(*ast.StructType); ok {
7778
for _, field := range st.Fields.List {
@@ -85,7 +86,7 @@ func extractSourceFields() ([]SourceField, error) {
8586
if ptr, ok := field.Type.(*ast.StarExpr); ok {
8687
if ident, ok := ptr.X.(*ast.Ident); ok {
8788
typeName := ident.Name
88-
if strings.HasPrefix(typeName, "Source") {
89+
if strings.HasPrefix(typeName, sourceTypeRef) {
8990
sourceFields = append(sourceFields, SourceField{
9091
Name: fieldName,
9192
TypeName: typeName,

0 commit comments

Comments
 (0)