summaryrefslogtreecommitdiff
path: root/goDep.helpers.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-11-29 18:15:25 -0600
committerJeff Carr <[email protected]>2024-11-29 18:15:25 -0600
commit4a79cccffd6cd20e42271eada567c4b8c0edc2f4 (patch)
tree4f1bf43db50e09956abe22d9fb3cb9d9b8ca4717 /goDep.helpers.go
parent7615317ca72347429f665dc7db9a0fe49d86cc55 (diff)
attempt to use go.wit.com/apps/autogenpb for sort
Diffstat (limited to 'goDep.helpers.go')
-rw-r--r--goDep.helpers.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/goDep.helpers.go b/goDep.helpers.go
new file mode 100644
index 0000000..470d750
--- /dev/null
+++ b/goDep.helpers.go
@@ -0,0 +1,52 @@
+package gitpb
+
+// this is becoming a standard format
+// todo: autogenerate this from the .proto file?
+
+import (
+ "time"
+)
+
+func (repo *Repo) DeleteGoDepByHash(hash string) *GoDep {
+ /*
+ refslock.Lock()
+ defer refslock.Unlock()
+
+ for i, _ := range repo.GoDeps {
+ if repo.GoDeps[i].Hash == hash {
+ repo.GoDeps[i] = repo.GoDeps[len(repo.GoDeps)-1]
+ repo.GoDeps = repo.GoDeps[:len(repo.GoDeps)-1]
+ return nil
+ }
+ }
+ */
+ return nil
+}
+
+// enforces no duplicate package names
+func (repo *Repo) AppendGoDep(newP *GoDep) bool {
+ /*
+ refslock.Lock()
+ defer refslock.Unlock()
+
+ for _, p := range repo.GoDeps {
+ if p.GoPath == newP.GoPath {
+ return false
+ }
+ }
+
+ repo.GoDeps = append(repo.GoDeps, newP)
+ */
+ return repo.GoDeps.AppendUniqueGoPath(newP)
+}
+
+// returns time.Duration since last scan of go.sum & go.mod
+func (repo *Repo) AgeGoDep() time.Duration {
+ t := time.Since(repo.LastGoDep.AsTime())
+ return t
+}
+
+// find a dependancy by the go path
+func (repo *Repo) FindGoDepByPath(gopath string) *GoDep {
+ return repo.GoDeps.FindByGoPath(gopath)
+}