The New Go programmer here is an apology if this is a well-worn area, but my Google search did not find the answer I'm looking for.
Short version. Can I, as a programmer, external to the main Go project, force to import my packages with a specific name. If so, how?
Long version: I recently tried installing a package bcryptfrom the next GitHub repository with the followinggo get
go get github.com/golang/crypto
The package loaded correctly in my workspace, but when I tried to import it, I got the following error
$ go run main.go main.go: 10: 2: code in the /path/to/go/src/github.com/golang/crypto/bcrypt directory awaiting import "golang.org/x/crypto/bcrypt"
i.e. Something said that this package should have been imported using golang.org/x/crypto/bcrypt. This pushed me away from what I really wanted:
go get golang.org/x/crypto/bcrypt
I would like to do something similar in my own packages - is this feature built into the Go packaging? Or do authors crypto/bcryptdo something at runtime to detect and reject invalid package import names?
source
share