Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix(build): get specific version of plugins

LinkinStars7ad8a83f8c05
diff --git a/internal/cli/build.go b/internal/cli/build.go
index 244249a5..2e59ca58 100644
--- a/internal/cli/build.go
+++ b/internal/cli/build.go
@@ -183,11 +183,14 @@ func createMainGoFile(b *buildingMaterial) (err error) {
}
for _, p := range b.plugins {
- if len(p.Path) == 0 {
- continue
+ // If user set a path, use it to replace the module with local path
+ if len(p.Path) > 0 {
+ replacement := fmt.Sprintf("%s@%s=%s", p.Name, p.Version, p.Path)
+ err = b.newExecCmd("go", "mod", "edit", "-replace", replacement).Run()
+ } else if len(p.Version) > 0 {
+ // If user specify a version, use it to get specific version of the module
+ err = b.newExecCmd("go", "get", fmt.Sprintf("%s@%s", p.Name, p.Version)).Run()
}
- replacement := fmt.Sprintf("%s@v%s=%s", p.Name, p.Version, p.Path)
- err = b.newExecCmd("go", "mod", "edit", "-replace", replacement).Run()
if err != nil {
return err
}