summaryrefslogtreecommitdiff
path: root/redoGoMod.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-17 20:47:09 -0600
committerJeff Carr <[email protected]>2024-12-17 20:47:09 -0600
commitea14fc629d4f6261242f8e45489e40fc0d5330ae (patch)
tree09ed6104afc8628dac7ed5fab6336c834dc53376 /redoGoMod.go
parent5434341272574da3baf8843c92c586b7429b468f (diff)
add SetGoPrimitive()v0.0.16
Diffstat (limited to 'redoGoMod.go')
-rw-r--r--redoGoMod.go20
1 files changed, 11 insertions, 9 deletions
diff --git a/redoGoMod.go b/redoGoMod.go
index f9b8fb5..956b920 100644
--- a/redoGoMod.go
+++ b/redoGoMod.go
@@ -53,28 +53,30 @@ func redoGoMod(repo *gitpb.Repo) error {
}
repo.GoDeps = nil
- repo.GoInfo.GoPrimitive = false
+ repo.SetGoPrimitive(false)
// if there is not a go.sum file, it better be a primitive golang project
if !repo.Exists("go.sum") {
// todo. fix this logic
- ok, err := repo.IsPrimitive()
+ err := repo.SetPrimitive()
if err != nil {
// this means this repo does not depend on any other package
log.Info("PRIMATIVE repo error:", repo.GetGoPath(), "err =", err)
return err
}
+ }
- if ok {
- // this means the repo is primitive so there is no go.sum
- repo.GoInfo.GoPrimitive = true
- repo.GoDeps = new(gitpb.GoDeps)
- return nil
- }
+ // now check if GoPrimitive is true
+ if repo.GetGoPrimitive() {
+ // perfect!
+ return nil
}
+ // well, it's not a primitive and we are still missing the go.sum file
if !repo.Exists("go.sum") {
- // this should never happen
+ // this means something else went wrong!
+ // display the go.mod file and try to figure out what happened
+ // maybe the format of go.mod changed in some future version of golang
data, _ := repo.ReadFile("go.mod")
log.Info(string(data))
return errors.New("missing go.sum file on non-primitive go.mod")