Found it https://go.dev/blog/using-go-modules#removing-unused-dependencies
go mod tidy
So basically, once the package is not being imported in any package you can perform a go mod tidy
and it will safely remove the unused dependencies.
And if you are vendoring the dependencies, then run the command below to make the module changes be applied in the vendor folder:
go mod vendor
Related Contents:
- Accessing local packages within a go module (go 1.11)
- missing go.sum entry for module providing package
- What does ‘incompatible’ in go.mod mean, will it cause harm?
- How to set GOPRIVATE environment variable
- Go update all modules
- How to upgrade the go version in a go mod
- Organize local code in packages using Go modules
- go mod: cannot find module providing package
- what is the purpose of `go mod vendor` command?
- Where is the module cache in golang?
- How do I migrate from Dep to Go Modules
- What is the difference between go get command and go mod download command
- Go get cannot find local packages when using multiple modules in a repo
- How to use a module that is outside of “GOPATH” in another module?
- How to assign string to bytes array
- How to delete an element from a Slice in Golang
- From io.Reader to string in Go
- Multiple goroutines listening on one channel
- Meaning of …interface{} (dot dot dot interface)
- How to reduce compiled file size?
- Go-compiled binary won’t run in an alpine docker container on Ubuntu host
- How do I get the local IP address in Go?
- GOBIN not set: cannot run go install
- Terminating a Process Started with os/exec in Golang
- Do Go switch/cases fallthrough or not?
- All possible GOOS value?
- Does Golang support variadic function?
- How can I get an error message in a string in Go?
- How to get the current function name
- How to use “internal” packages?
- Golang defer behavior
- What happens if I don’t cancel a Context?
- Go: returning from defer
- How to stop json.Marshal from escaping < and >?
- In Go is it possible to iterate over a custom type?
- Add days to date in Go
- nil slices vs non-nil slices vs empty slices in Go language
- First class functions in Go
- go module @latest found but does not contain package
- Unmarshaling Into an Interface{} and Then Performing Type Assertion
- Idiomatic goroutine termination and error handling
- How do you statically link a c library in go using cgo?
- Go array initialization
- Why is rune in golang an alias for int32 and not uint32?
- Pass slice as function argument, and modify the original slice
- Public, Private – Upper Case, Lower Case:
- Convert []string to []interface{} [duplicate]
- Reading log files as they’re updated in Go
- How to find the difference between two slices of strings
- How to log messages to the console and a file both in golang?