Add any configured Go Workspace file to the config watcher

Fixes #10556
This commit is contained in:
Bjørn Erik Pedersen 2022-12-19 15:50:53 +01:00
parent 0d4b17d4c0
commit 6db527483d
4 changed files with 27 additions and 4 deletions

View file

@ -107,9 +107,15 @@ func (h *Client) collect(tidy bool) (ModulesConfig, *collector) {
}
}*/
var workspaceFilename string
if h.ccfg.ModuleConfig.Workspace != WorkspaceDisabled {
workspaceFilename = h.ccfg.ModuleConfig.Workspace
}
return ModulesConfig{
AllModules: c.modules,
GoModulesFilename: c.GoModulesFilename,
AllModules: c.modules,
GoModulesFilename: c.GoModulesFilename,
GoWorkspaceFilename: workspaceFilename,
}, c
}
@ -122,6 +128,9 @@ type ModulesConfig struct {
// Set if this is a Go modules enabled project.
GoModulesFilename string
// Set if a Go workspace file is configured.
GoWorkspaceFilename string
}
func (m *ModulesConfig) setActiveMods(logger loggers.Logger) error {

View file

@ -15,6 +15,7 @@ package modules
import (
"fmt"
"os"
"path/filepath"
"strings"
@ -261,6 +262,9 @@ func decodeConfig(cfg config.Provider, pathReplacements map[string]string) (Conf
workingDir := cfg.GetString("workingDir")
c.Workspace = filepath.Join(workingDir, c.Workspace)
}
if _, err := os.Stat(c.Workspace); err != nil {
return c, fmt.Errorf("module workspace %q does not exist", c.Workspace)
}
}
}