aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/config.go')
-rw-r--r--modules/config.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/modules/config.go b/modules/config.go
index 08154bc11..86166300a 100644
--- a/modules/config.go
+++ b/modules/config.go
@@ -26,6 +26,8 @@ import (
"github.com/mitchellh/mapstructure"
)
+const WorkspaceDisabled = "off"
+
var DefaultModuleConfig = Config{
// Default to direct, which means "git clone" and similar. We
@@ -41,6 +43,9 @@ var DefaultModuleConfig = Config{
// treated as private.
Private: "*.*",
+ // Default is no workspace resolution.
+ Workspace: WorkspaceDisabled,
+
// A list of replacement directives mapping a module path to a directory
// or a theme component in the themes folder.
// Note that this will turn the component into a traditional theme component
@@ -247,6 +252,16 @@ func decodeConfig(cfg config.Provider, pathReplacements map[string]string) (Conf
c.Mounts[i] = mnt
}
+ if c.Workspace == "" {
+ c.Workspace = WorkspaceDisabled
+ }
+ if c.Workspace != WorkspaceDisabled {
+ c.Workspace = filepath.Clean(c.Workspace)
+ if !filepath.IsAbs(c.Workspace) {
+ workingDir := cfg.GetString("workingDir")
+ c.Workspace = filepath.Join(workingDir, c.Workspace)
+ }
+ }
}
if themeSet {
@@ -294,8 +309,9 @@ type Config struct {
// Configures GOPRIVATE.
Private string
- // Set the workspace file to use, e.g. hugo.work.
- // Enables Go "Workspace" mode.
+ // Defaults to "off".
+ // Set to a work file, e.g. hugo.work, to enable Go "Workspace" mode.
+ // Can be relative to the working directory or absolute.
// Requires Go 1.18+
// See https://tip.golang.org/doc/go1.18
Workspace string