How can I get Goland to lint my go.mod
correctly and not report "missing dependency" errors for a module I am maintaining in a sub directory of my main project?
I'm trying to follow the pattern in hashicorp's vault project where I maintain an api
module in a sub folder (that can be imported by others without dragging in all deps used by my main project.) Just like in vault, I reference the api module by url in my main project's go.mod
and override it with a replace
pointing to the relative path location.
module github.com/hashicorp/vault
go 1.16
replace github.com/hashicorp/vault/api => ./api
// ...
require (
// ...
github.com/hashicorp/vault/api v1.0.5-0.20210210214158-405eced08457
// ...
)
All this works as expected from a build perspective (and dependency resolution within the source code), however Goland is highlighting both the import statement and the replace statement in my main project's go.mod
in red (the error is "missing dependency"). The red lightbulb suggests I "Sync Dependencies" which i have tried, but after a "Finished Successfully" message, the error remains.
I am using Goland 2020.3.5 and go 1.16.3. My project is outside of my GOPATH and I have go modules enabled in the Goland settings menu.
Just to reiterate, everything builds correctly, however the linting for my go.mod acts like there is a missing dependency error.
Upgrading to the latest version of Goland (2021.1.3) solved the issue. Thanks @s0xzwasd !