Most people who have had some experience with Golang have probably had struggled with its dependency management system. Starting with vendor, managed by community driven tools with varied features and user experiences, to the short-lived, Google-branded dep tool, now the module mechanism with official tooling that controls not only dependencies but their find-grained versions.
Some of the official command tools changed their behavior along the way. go get was once used to download and install packages onto the local system. It's now repurposed to resolve dependencies of the current module (modifying go.mod file) and install them, in the current, module-aware realm. What if you simply need the old behavior, i.e. installing a package without messing with your current Golang code? You have the following two options.
1. If this package you're trying to install has absolutely nothing to do with your current project, you can disable the module aware mode temporarily.
2. If this package is not a direct dependency of your project, but relates to your code in some way, e.g. a CI tool like goimports that checks your code, you might as well record its version in your project, so that you don't end up saying "it works in my environment" some day.
没有评论:
发表评论