Cobra: Issue generating markdown pages for commands when using vgo

Created on 7 Jan 2019  Â·  6Comments  Â·  Source: spf13/cobra

I'm using vgo and recently added ability to generate markdown pages for entire command tree per this doc https://github.com/spf13/cobra/blob/master/doc/md_docs.md. It doesn't seem to work with vgo. Getting following error when running vgo build

github.com/cpuguy83/go-md2man/md2man ../../../../pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:11:16: undefined: blackfriday.EXTENSION_NO_INTRA_EMPHASIS ../../../../pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:12:16: undefined: blackfriday.EXTENSION_TABLES ../../../../pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:13:16: undefined: blackfriday.EXTENSION_FENCED_CODE ../../../../pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:14:16: undefined: blackfriday.EXTENSION_AUTOLINK ../../../../pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:15:16: undefined: blackfriday.EXTENSION_SPACE_HEADERS ../../../../pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:16:16: undefined: blackfriday.EXTENSION_FOOTNOTES ../../../../pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:17:16: undefined: blackfriday.EXTENSION_TITLEBLOCK ../../../../pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:19:29: too many arguments to conversion to blackfriday.Markdown: blackfriday.Markdown(doc, renderer, extensions) ../../../../pkg/mod/github.com/cpuguy83/[email protected]/md2man/roff.go:19:23: cannot use roffRenderer literal (type *roffRenderer) as type blackfriday.Renderer in return argument: *roffRenderer does not implement blackfriday.Renderer (missing RenderFooter method) ../../../../pkg/mod/github.com/cpuguy83/[email protected]/md2man/roff.go:102:11: undefined: blackfriday.LIST_TYPE_ORDERED ../../../../pkg/mod/github.com/cpuguy83/[email protected]/md2man/roff.go:102:11: too many errors

Most helpful comment

Thought I would post my experience in case it helps others. I also ran into the errors previously stated when building my project with go module support. The build errors were:

$ go build
# github.com/cpuguy83/go-md2man/md2man
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:11:16: undefined: blackfriday.EXTENSION_NO_INTRA_EMPHASIS
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:12:16: undefined: blackfriday.EXTENSION_TABLES
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:13:16: undefined: blackfriday.EXTENSION_FENCED_CODE
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:14:16: undefined: blackfriday.EXTENSION_AUTOLINK
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:15:16: undefined: blackfriday.EXTENSION_SPACE_HEADERS
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:16:16: undefined: blackfriday.EXTENSION_FOOTNOTES
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:17:16: undefined: blackfriday.EXTENSION_TITLEBLOCK
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:19:29: too many arguments to conversion to blackfriday.Markdown: blackfriday.Markdown(doc, renderer, extensions)
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/roff.go:19:9: cannot use roffRenderer literal (type *roffRenderer) as type blackfriday.Renderer in return argument:
    *roffRenderer does not implement blackfriday.Renderer (missing RenderFooter method)
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/roff.go:102:11: undefined: blackfriday.LIST_TYPE_ORDERED
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/roff.go:102:11: too many errors

looking at go.sum, it was trying to use the latest tag release of 1.0.8:

github.com/cpuguy83/go-md2man v1.0.8 h1:DwoNytLphI8hzS2Af4D0dfaEaiSq2bN05mEm4R6vf8M=
github.com/cpuguy83/go-md2man v1.0.8/go.mod h1:N6JayAiVKtlHSnuTCeuLSQVs75hb8q+dYQLjr7cDsKY=

I told go modules to use the latest master commit instead, and it seems to work:

go get github.com/cpuguy83/go-md2man@691ee98543af2f262f35fbb54bdd42f00b9b9cc5
go build
$ go mod why github.com/cpuguy83/go-md2man/md2man
# github.com/cpuguy83/go-md2man/md2man
github.com/benmcclelland/test/cmd
github.com/spf13/cobra/doc
github.com/cpuguy83/go-md2man/md2man

Looks like maybe this is making use of a not yet released interface?

All 6 comments

Thought I would post my experience in case it helps others. I also ran into the errors previously stated when building my project with go module support. The build errors were:

$ go build
# github.com/cpuguy83/go-md2man/md2man
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:11:16: undefined: blackfriday.EXTENSION_NO_INTRA_EMPHASIS
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:12:16: undefined: blackfriday.EXTENSION_TABLES
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:13:16: undefined: blackfriday.EXTENSION_FENCED_CODE
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:14:16: undefined: blackfriday.EXTENSION_AUTOLINK
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:15:16: undefined: blackfriday.EXTENSION_SPACE_HEADERS
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:16:16: undefined: blackfriday.EXTENSION_FOOTNOTES
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:17:16: undefined: blackfriday.EXTENSION_TITLEBLOCK
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/md2man.go:19:29: too many arguments to conversion to blackfriday.Markdown: blackfriday.Markdown(doc, renderer, extensions)
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/roff.go:19:9: cannot use roffRenderer literal (type *roffRenderer) as type blackfriday.Renderer in return argument:
    *roffRenderer does not implement blackfriday.Renderer (missing RenderFooter method)
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/roff.go:102:11: undefined: blackfriday.LIST_TYPE_ORDERED
../../../go/pkg/mod/github.com/cpuguy83/[email protected]/md2man/roff.go:102:11: too many errors

looking at go.sum, it was trying to use the latest tag release of 1.0.8:

github.com/cpuguy83/go-md2man v1.0.8 h1:DwoNytLphI8hzS2Af4D0dfaEaiSq2bN05mEm4R6vf8M=
github.com/cpuguy83/go-md2man v1.0.8/go.mod h1:N6JayAiVKtlHSnuTCeuLSQVs75hb8q+dYQLjr7cDsKY=

I told go modules to use the latest master commit instead, and it seems to work:

go get github.com/cpuguy83/go-md2man@691ee98543af2f262f35fbb54bdd42f00b9b9cc5
go build
$ go mod why github.com/cpuguy83/go-md2man/md2man
# github.com/cpuguy83/go-md2man/md2man
github.com/benmcclelland/test/cmd
github.com/spf13/cobra/doc
github.com/cpuguy83/go-md2man/md2man

Looks like maybe this is making use of a not yet released interface?

Just ran into the same issue. Thanks for doing the legwork on straightening out the dependency version, @benmcclelland!

thanks @benmcclelland

go mod should work now.

I ran to this wall today, and I don't understand it.

â–¶ go mod graph | grep md2
github.com/spf13/cobra github.com/cpuguy83/[email protected]
github.com/cpuguy83/[email protected] github.com/russross/[email protected]

And there is no other Blackfriday reference, yet when I do go get -u from Cobra of from Hugo, it insists about pulling in BF v2 which does not make much sense. Sounds like a Go bug.

If my understanding is correct, I believe this project needs to be updated to use github.com/cpuguy83/go-md2man/v2 in order to avoid the broken v2.0.0 release of blackfriday.

Was this page helpful?
0 / 5 - 0 ratings