Removing dependencies

What is the best way to remove dependency in Golang?

what do you mean with “removing dependency”?

  • removing it from your project?
    Remove it from go.mod file and run go mod tidy (of course it works only if your code doesn’t use the dependency
1 Like

Yes, from the project. Thanks.

  1. Run go mod tidy: Next, run the go mod tidy command in your terminal. This command will scan your project’s go.mod file and remove any unused dependencies. If the package you removed wasn’t being used, go mod tidy will automatically remove it from the go.mod file as well.
1 Like