File tree Expand file tree Collapse file tree 2 files changed +3
-2
lines changed
Expand file tree Collapse file tree 2 files changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -23,8 +23,8 @@ var genCommentRegexp = regexp.MustCompile(`^// Code generated .* DO NOT EDIT\.$`
2323// IsGeneratedFile reports whether the file has been generated automatically.
2424// If file is nil, IsGeneratedFile will return false.
2525func IsGeneratedFile (file * ast.File ) bool {
26- if file == nil || file .Doc == nil {
26+ if file == nil || len ( file .Comments ) == 0 {
2727 return false
2828 }
29- return genCommentRegexp .MatchString (file .Doc .List [0 ].Text )
29+ return genCommentRegexp .MatchString (file .Comments [ 0 ] .List [0 ].Text )
3030}
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ func TestIsGeneratedFile(t *testing.T) {
2020 "true" : {"// Code generated by test; DO NOT EDIT." , true },
2121 "false" : {"//Code generated by test; DO NOT EDIT." , false },
2222 "empty" : {"" , false },
23+ "blank" : {"// Code generated by test; DO NOT EDIT.\n " , true },
2324 }
2425
2526 for name , tt := range cases {
You can’t perform that action at this time.
0 commit comments