Rename ModulePath -> PackagePath

Technically they are packages to be imported, not necessarily paths to
the containing Go module.
This commit is contained in:
Matthew Holt 2020-07-15 17:45:32 -06:00
parent 3742b72df8
commit 1d18c5862c
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
3 changed files with 12 additions and 12 deletions

View file

@ -131,12 +131,12 @@ func setEnv(env []string, set string) []string {
// Dependency pairs a Go module path with a version. // Dependency pairs a Go module path with a version.
type Dependency struct { type Dependency struct {
// The name (path) of the Go module. If at a version > 1, it // The name (import path) of the Go package. If at a version > 1,
// should contain semantic import version suffix (i.e. "/v2"). // it should contain semantic import version (i.e. "/v2").
// Used with `go get` // Used with `go get`.
ModulePath string `json:"module_path,omitempty"` PackagePath string `json:"module_path,omitempty"`
// The version of the Go module, like used with `go get`. // The version of the Go module, as used with `go get`.
Version string `json:"version,omitempty"` Version string `json:"version,omitempty"`
} }

View file

@ -70,8 +70,8 @@ func runBuild(ctx context.Context, args []string) error {
} }
mod = strings.TrimSuffix(mod, "/") // easy to accidentally leave a trailing slash if pasting from a URL, but is invalid for Go modules mod = strings.TrimSuffix(mod, "/") // easy to accidentally leave a trailing slash if pasting from a URL, but is invalid for Go modules
plugins = append(plugins, xcaddy.Dependency{ plugins = append(plugins, xcaddy.Dependency{
ModulePath: mod, PackagePath: mod,
Version: ver, Version: ver,
}) })
if repl != "" { if repl != "" {
replacements = append(replacements, xcaddy.Replace{ replacements = append(replacements, xcaddy.Replace{
@ -211,7 +211,7 @@ func runDev(ctx context.Context, args []string) error {
}, },
CaddyVersion: caddyVersion, CaddyVersion: caddyVersion,
Plugins: []xcaddy.Dependency{ Plugins: []xcaddy.Dependency{
{ModulePath: importPath}, {PackagePath: importPath},
}, },
Replacements: replacements, Replacements: replacements,
RaceDetector: raceDetector, RaceDetector: raceDetector,

View file

@ -41,7 +41,7 @@ func (b Builder) newEnvironment(ctx context.Context) (*environment, error) {
// clean up any SIV-incompatible module paths real quick // clean up any SIV-incompatible module paths real quick
for i, p := range b.Plugins { for i, p := range b.Plugins {
b.Plugins[i].ModulePath, err = versionedModulePath(p.ModulePath, p.Version) b.Plugins[i].PackagePath, err = versionedModulePath(p.PackagePath, p.Version)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -52,7 +52,7 @@ func (b Builder) newEnvironment(ctx context.Context) (*environment, error) {
CaddyModule: caddyModulePath, CaddyModule: caddyModulePath,
} }
for _, p := range b.Plugins { for _, p := range b.Plugins {
tplCtx.Plugins = append(tplCtx.Plugins, p.ModulePath) tplCtx.Plugins = append(tplCtx.Plugins, p.PackagePath)
} }
// evaluate the template for the main module // evaluate the template for the main module
@ -139,11 +139,11 @@ nextPlugin:
// a plugin package may be a subfolder of a module, i.e. // a plugin package may be a subfolder of a module, i.e.
// foo/a/plugin is within module foo/a. // foo/a/plugin is within module foo/a.
for repl := range replaced { for repl := range replaced {
if strings.HasPrefix(p.ModulePath, repl) { if strings.HasPrefix(p.PackagePath, repl) {
continue nextPlugin continue nextPlugin
} }
} }
err = env.execGoGet(ctx, p.ModulePath, p.Version) err = env.execGoGet(ctx, p.PackagePath, p.Version)
if err != nil { if err != nil {
return nil, err return nil, err
} }