Skip to content

Commit

Permalink
Rename ModulePath -> PackagePath
Browse files Browse the repository at this point in the history
Technically they are packages to be imported, not necessarily paths to
the containing Go module.
  • Loading branch information
mholt committed Jul 15, 2020
1 parent 3742b72 commit 1d18c58
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ func setEnv(env []string, set string) []string {

// Dependency pairs a Go module path with a version.
type Dependency struct {
// The name (path) of the Go module. If at a version > 1, it
// should contain semantic import version suffix (i.e. "/v2").
// Used with `go get`
ModulePath string `json:"module_path,omitempty"`
// The name (import path) of the Go package. If at a version > 1,
// it should contain semantic import version (i.e. "/v2").
// Used with `go get`.
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"`
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/xcaddy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
plugins = append(plugins, xcaddy.Dependency{
ModulePath: mod,
Version: ver,
PackagePath: mod,
Version: ver,
})
if repl != "" {
replacements = append(replacements, xcaddy.Replace{
Expand Down Expand Up @@ -211,7 +211,7 @@ func runDev(ctx context.Context, args []string) error {
},
CaddyVersion: caddyVersion,
Plugins: []xcaddy.Dependency{
{ModulePath: importPath},
{PackagePath: importPath},
},
Replacements: replacements,
RaceDetector: raceDetector,
Expand Down
8 changes: 4 additions & 4 deletions environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (b Builder) newEnvironment(ctx context.Context) (*environment, error) {

// clean up any SIV-incompatible module paths real quick
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 {
return nil, err
}
Expand All @@ -52,7 +52,7 @@ func (b Builder) newEnvironment(ctx context.Context) (*environment, error) {
CaddyModule: caddyModulePath,
}
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
Expand Down Expand Up @@ -139,11 +139,11 @@ nextPlugin:
// a plugin package may be a subfolder of a module, i.e.
// foo/a/plugin is within module foo/a.
for repl := range replaced {
if strings.HasPrefix(p.ModulePath, repl) {
if strings.HasPrefix(p.PackagePath, repl) {
continue nextPlugin
}
}
err = env.execGoGet(ctx, p.ModulePath, p.Version)
err = env.execGoGet(ctx, p.PackagePath, p.Version)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 1d18c58

Please sign in to comment.