1

Is it possible to use go doc for a 'downloaded' package without creation of a module?

~/tt$ ls # empty

~/tt$ go install go.mongodb.org/mongo-driver/bson@latest
package go.mongodb.org/mongo-driver/bson is not a main package

~/tt$ go doc go.mongodb.org/mongo-driver/bson
doc: no required module provides package go.mongodb.org/mongo-driver/bson: go.mod file not found in current directory or any parent directory; see 'go help modules'
exit status 1

If you create a module that includes it, it works.

~/tt$ go mod init testing
go: creating new go.mod: module testing

~/tt$ go get go.mongodb.org/mongo-driver/bson
go: added github.com/go-stack/stack v1.8.0
go: added go.mongodb.org/mongo-driver v1.9.1

~/tt$ go doc go.mongodb.org/mongo-driver/bson | head -2
package bson // import "go.mongodb.org/mongo-driver/bson"

In both cases, the bson package is located in /home/ubuntu/go/pkg/mod/go.mongodb.org/mongo-driver@v1.9.1/bson. This feels that stdlib is getting special treatment versus GOPATH/Modules as go doc net work without creation of using go.mod.

I looked around and suspect I missed some doc about this, any pointers appreciated.

(update: using 1.19beta1)

0 Answers0