Skip to content

Commit 5d32d36

Browse files
aykevldeadprogram
authored andcommitted
doc-gen: add some error checking
This should diagnose a problem where no output is generated.
1 parent 68c63d8 commit 5d32d36

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

doc-gen/main.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ func writeDoc(out io.Writer, target string, buildTags []string, goos, goarch str
139139
log.Fatal(err)
140140
}
141141

142+
// Do some sanity checking.
143+
if len(pkgs[0].Errors) != 0 {
144+
for _, err := range pkgs[0].Errors {
145+
fmt.Fprintln(os.Stderr, err)
146+
}
147+
os.Exit(1)
148+
}
149+
if len(pkgs[0].CompiledGoFiles) == 0 {
150+
fmt.Fprintln(os.Stderr, "no compiled Go files found for target:", target)
151+
os.Exit(1)
152+
}
153+
142154
// Parse all to-be-compiled files.
143155
syntax := make([]*ast.File, len(pkgs[0].CompiledGoFiles))
144156
fset := token.NewFileSet()

0 commit comments

Comments
 (0)