Original post

I’d like to replace “encoding/json” with “https://github.com/segmentio/encoding

One option would be to replace all import statements in every file that imports JSON. To avoid this, I would like to use the replace directive in go mod such as replace encoding/json => github.com/segmentio/encoding/json. However, this command produces the error go.mod:5: replacement module without version must be directory path (rooted or starting with ./ or ../)

Is there any way to alias a package without editing every single import statement?

Alternatively, is there a way to find the directory where a module is installed and use that in the replace directive?