From dae467dc8ded7bcf46f4191671b6a653c37ee43f Mon Sep 17 00:00:00 2001 From: Jeroen Mulkers <jeroen.mulkers@gmail.com> Date: Mon, 10 Aug 2020 22:07:24 +0200 Subject: [PATCH] Fix getGoDocString for go>=1.13 The go documentation formatting has been changed slightly in go 1.13. This commit takes care of these changes. --- doc/apigen.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/apigen.go b/doc/apigen.go index 477250858..c741db4f8 100644 --- a/doc/apigen.go +++ b/doc/apigen.go @@ -52,10 +52,11 @@ func getGoDocString(packageName, identifier string) string { docString := "" cmd := exec.Command("go", "doc", packageName, identifier) stdout, err := cmd.Output() - if err == nil && string(stdout)[:4] == "func" { // we only look for doc strings of functions - // the doc string of a function is on the second line - // (and possible continued on the third line, if not, then the third line is empty) - docString = strings.Join(strings.SplitAfterN(string(stdout), "\n", 4)[1:3], " ") + outputLines := strings.Split(string(stdout), "\n") + if err == nil && outputLines[2][:4] == "func" { // we only look for doc strings of functions + // the doc string of a function is on the fourth line + // (and possible continued on the fifth line, if not, then the fifth line is empty) + docString = strings.Join(outputLines[3:5], " ") } return docString }