summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-01 19:27:30 -0600
committerJeff Carr <[email protected]>2024-12-01 19:27:30 -0600
commit9d95b189135422a720cb00f8b0ca8546e7fdc9b5 (patch)
tree34299ad83167152bf4681b4264751b5c4f9cdf50
Day 1. pull these out from protobuf librariesv0.0.2v0.0.1
-rw-r--r--.gitignore11
-rw-r--r--Makefile6
-rw-r--r--forgeConfig/Makefile48
-rw-r--r--forgeConfig/argv.go50
-rw-r--r--forgeConfig/main.go133
-rw-r--r--scanGoSrc/Makefile25
-rw-r--r--scanGoSrc/argv.go50
-rw-r--r--scanGoSrc/main.go54
-rw-r--r--validate/Makefile21
-rw-r--r--validate/argv.go42
-rw-r--r--validate/main.go97
-rw-r--r--virtbuf-example/Makefile17
-rw-r--r--virtbuf-example/main.go91
-rw-r--r--zoopb-example/Makefile17
-rw-r--r--zoopb-example/main.go71
15 files changed, 733 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a402043
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,11 @@
+*.swp
+go.mod
+go.sum
+/files/*
+/work/*
+
+forgeConfig/forgeConfig
+scanGoSrc/scanGoSrc
+validate/validate
+virtbuf-example/virtbuf-example
+zoopb-example/zoopb-example
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..416f066
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,6 @@
+all:
+ make -C forgeConfig
+ make -C scanGoSrc
+ make -C validate
+ make -C virtbuf-example
+ make -C zoopb-example
diff --git a/forgeConfig/Makefile b/forgeConfig/Makefile
new file mode 100644
index 0000000..89ab023
--- /dev/null
+++ b/forgeConfig/Makefile
@@ -0,0 +1,48 @@
+VERSION = $(shell git describe --tags)
+BUILDTIME = $(shell date +%Y.%m.%d)
+
+build:
+ GO111MODULE=off go build \
+ -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
+
+test2:
+ ./forgeConfig
+ FORGE_HOME=/tmp/forge ./forgeConfig
+ FORGE_HOME=/tmp/forge ./forgeConfig --list
+
+install:
+ GO111MODULE=off go install \
+ -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
+
+test:
+ ./forgeConfig --list
+ ./forgeConfig --add --gopath 'go.wit.com/apps/foo'
+ ./forgeConfig --add --gopath 'go.wit.com/apps/foowrite' --writable
+ ./forgeConfig --add --gopath 'gitea.wit.com' --directory
+ ./forgeConfig --add --gopath 'git.wit.org' --directory
+ ./forgeConfig --delete --gopath 'go.wit.com/apps/helloworld'
+ ./forgeConfig --list
+
+list:
+ ./forgeConfig --list
+
+add:
+ ./forgeConfig --add --name 'foo' --gopath 'go.wit.com/apps/foo'
+
+update:
+ ./forgeConfig --update --name 'foo' --gopath 'more stuff but not memory corruption?'
+
+corruptMemory:
+ ./forgeConfig --update --name 'foo' --gopath 'blah'
+
+goimports:
+ goimports -w *.go
+
+prep:
+ go get -v -t -u
+
+run:
+ go run *.go
+
+clean:
+ -rm -f forgeConfig
diff --git a/forgeConfig/argv.go b/forgeConfig/argv.go
new file mode 100644
index 0000000..635989f
--- /dev/null
+++ b/forgeConfig/argv.go
@@ -0,0 +1,50 @@
+package main
+
+import (
+ "os"
+
+ "go.wit.com/dev/alexflint/arg"
+)
+
+var argv args
+
+type args struct {
+ ConfigDir string `arg:"env:FORGE_HOME" help:"defaults to ~/.config/forge/"`
+ List bool `arg:"--list" default:"false" help:"list repos in your config"`
+ Add bool `arg:"--add" default:"false" help:"add a new repo"`
+ Delete bool `arg:"--delete" default:"false" help:"delete a repo"`
+ Update bool `arg:"--update" default:"false" help:"update a repo"`
+ GoPath string `arg:"--gopath" help:"gopath of the repo"`
+ Directory bool `arg:"--directory" default:"false" help:"repo is a directory to match against"`
+ ReadOnly bool `arg:"--readonly" default:"false" help:"repo is readonly"`
+ Writable bool `arg:"--writable" default:"false" help:"repo is writable"`
+ Favorite bool `arg:"--favorite" default:"false" help:"forge will always go-clone or git clone this"`
+ Private bool `arg:"--private" default:"false" help:"repo can not be published"`
+ Interesting bool `arg:"--interesting" default:"false" help:"something you decided was cool"`
+}
+
+func (a args) Description() string {
+ return `
+ forgeConfig -- add entries to your config files
+
+This is just example protobuf code to test forgepb is working
+but it could be used to automagically create a config file too.
+
+If you need to change your config file, just edit the forge.text or forge.json
+files then remove the forge.pb and ConfigLoad() will attempt to load those files instead
+`
+}
+
+func (args) Version() string {
+ return "virtigo " + VERSION
+}
+
+func init() {
+ var pp *arg.Parser
+ pp = arg.MustParse(&argv)
+
+ if pp == nil {
+ pp.WriteHelp(os.Stdout)
+ os.Exit(0)
+ }
+}
diff --git a/forgeConfig/main.go b/forgeConfig/main.go
new file mode 100644
index 0000000..36b0b71
--- /dev/null
+++ b/forgeConfig/main.go
@@ -0,0 +1,133 @@
+package main
+
+import (
+ "os"
+
+ "go.wit.com/lib/protobuf/forgepb"
+ "go.wit.com/log"
+)
+
+// sent via ldflags
+var VERSION string
+
+func main() {
+ f := forgepb.Init()
+
+ if argv.List {
+ f.ConfigPrintTable()
+ loop := f.Config.SortByGoPath() // get the list of forge configs
+ for loop.Scan() {
+ r := loop.Next()
+ log.Info("repo:", r.GoPath)
+ }
+ os.Exit(0)
+ }
+
+ // try to delete, then save config and exit
+ if argv.Delete {
+ if f.Config.DeleteByGoPath(argv.GoPath) {
+ log.Info("deleted", argv.GoPath, "did not exist. did nothing")
+ os.Exit(0)
+ }
+ log.Info("deleted", argv.GoPath, "ok")
+ f.ConfigSave()
+ os.Exit(0)
+ }
+
+ // try to update, then save config and exit
+ if argv.Update {
+ /*
+ if f.UpdateGoPath(argv.Name, argv.GoPath) {
+ // save updated config file
+ repos.ConfigSave()
+ }
+ */
+ os.Exit(0)
+ }
+
+ // try to add, then save config and exit
+ if argv.Add {
+ log.Info("going to add a new repo", argv.GoPath)
+ new1 := forgepb.ForgeConfig{
+ GoPath: argv.GoPath,
+ Writable: argv.Writable,
+ ReadOnly: argv.ReadOnly,
+ Private: argv.Private,
+ Directory: argv.Directory,
+ Favorite: argv.Favorite,
+ Interesting: argv.Interesting,
+ }
+
+ if f.Config.Append(&new1) {
+ log.Info("added", new1.GoPath, "ok")
+ } else {
+ log.Info("added", new1.GoPath, "failed")
+ os.Exit(-1)
+ }
+ f.ConfigSave()
+ os.Exit(0)
+ }
+
+ // testMemoryCorruption(f)
+ f.ConfigSave()
+}
+
+/*
+// this fucks shit up
+func testMemoryCorruption(all *forgepb.Repos) *forgepb.Repos {
+ new1 := new(forgepb.Repo)
+ new1.Name = "bash1"
+ new1.Version = "5.2.21"
+ if all.Append(new1) {
+ log.Info("added", new1.Name, "ok")
+ } else {
+ log.Info("added", new1.Name, "failed")
+ }
+
+ new1 = new(forgepb.Repo)
+ new1.Name = "zookeeper1"
+ new1.Debname = "zookeeper-go"
+ if all.Append(new1) {
+ log.Info("added", new1.Name, "ok")
+ } else {
+ log.Info("added", new1.Name, "failed")
+ }
+
+ new1 = new(forgepb.Repo)
+ new1.Name = "wit-package"
+ new1.Private = true
+ if all.Append(new1) {
+ log.Info("added", new1.Name, "ok")
+ } else {
+ log.Info("added", new1.Name, "failed")
+ }
+
+ new1 = new(forgepb.Repo)
+ new1.Name = "networkQuality"
+ new1.Debname = "networkquality"
+ new1.Readonly = true
+ if all.Append(new1) {
+ log.Info("added", new1.Name, "ok")
+ } else {
+ log.Info("added", new1.Name, "failed")
+ }
+
+ new2 := new(forgepb.Repo)
+ new2.Name = "go-clone"
+ new2.Version = "0.6.8" // good version of the macos
+ if all.Append(new2) {
+ log.Info("added", new2.Name, "ok")
+ } else {
+ log.Info("added", new2.Name, "failed")
+ }
+
+ if all.Append(new2) {
+ log.Info("added", new2.Name, "ok (this is bad)")
+ } else {
+ log.Info("added", new2.Name, "failed (but ok)")
+ }
+
+ fmt.Println("packages are:", len(all.Repos))
+ return all
+}
+*/
diff --git a/scanGoSrc/Makefile b/scanGoSrc/Makefile
new file mode 100644
index 0000000..eeaa73f
--- /dev/null
+++ b/scanGoSrc/Makefile
@@ -0,0 +1,25 @@
+VERSION = $(shell git describe --tags)
+BUILDTIME = $(shell date +%Y.%m.%d)
+
+build:
+ GO111MODULE=off go build \
+ -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
+
+test:
+ FORGE_HOME=/tmp/forge ./scanGoSrc
+
+install:
+ GO111MODULE=off go install \
+ -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
+
+goimports:
+ goimports -w *.go
+
+prep:
+ go get -v -t -u
+
+run:
+ go run *.go
+
+clean:
+ -rm -f scanGoSrc
diff --git a/scanGoSrc/argv.go b/scanGoSrc/argv.go
new file mode 100644
index 0000000..635989f
--- /dev/null
+++ b/scanGoSrc/argv.go
@@ -0,0 +1,50 @@
+package main
+
+import (
+ "os"
+
+ "go.wit.com/dev/alexflint/arg"
+)
+
+var argv args
+
+type args struct {
+ ConfigDir string `arg:"env:FORGE_HOME" help:"defaults to ~/.config/forge/"`
+ List bool `arg:"--list" default:"false" help:"list repos in your config"`
+ Add bool `arg:"--add" default:"false" help:"add a new repo"`
+ Delete bool `arg:"--delete" default:"false" help:"delete a repo"`
+ Update bool `arg:"--update" default:"false" help:"update a repo"`
+ GoPath string `arg:"--gopath" help:"gopath of the repo"`
+ Directory bool `arg:"--directory" default:"false" help:"repo is a directory to match against"`
+ ReadOnly bool `arg:"--readonly" default:"false" help:"repo is readonly"`
+ Writable bool `arg:"--writable" default:"false" help:"repo is writable"`
+ Favorite bool `arg:"--favorite" default:"false" help:"forge will always go-clone or git clone this"`
+ Private bool `arg:"--private" default:"false" help:"repo can not be published"`
+ Interesting bool `arg:"--interesting" default:"false" help:"something you decided was cool"`
+}
+
+func (a args) Description() string {
+ return `
+ forgeConfig -- add entries to your config files
+
+This is just example protobuf code to test forgepb is working
+but it could be used to automagically create a config file too.
+
+If you need to change your config file, just edit the forge.text or forge.json
+files then remove the forge.pb and ConfigLoad() will attempt to load those files instead
+`
+}
+
+func (args) Version() string {
+ return "virtigo " + VERSION
+}
+
+func init() {
+ var pp *arg.Parser
+ pp = arg.MustParse(&argv)
+
+ if pp == nil {
+ pp.WriteHelp(os.Stdout)
+ os.Exit(0)
+ }
+}
diff --git a/scanGoSrc/main.go b/scanGoSrc/main.go
new file mode 100644
index 0000000..f59ea77
--- /dev/null
+++ b/scanGoSrc/main.go
@@ -0,0 +1,54 @@
+package main
+
+import (
+ "os"
+
+ "go.wit.com/lib/protobuf/gitpb"
+ "go.wit.com/log"
+)
+
+// sent via ldflags
+var VERSION string
+
+func main() {
+ var repos *gitpb.Repos
+ repos = new(gitpb.Repos)
+
+ newr, err := repos.NewGoPath("/home/jcarr/go/src", "go.wit.com/apps/wit-package")
+ if err != nil {
+ log.Info("init failed", err)
+ panic("crapnuts")
+ } else {
+ log.Info("init worked for", newr.GoPath)
+ }
+
+ newr, err = repos.NewGoPath("/home/jcarr/go/src", "go.wit.com/apps/notathing")
+ if err != nil {
+ log.Info("init failed correctly:", err)
+ } else {
+ log.Info("init should have failed for", newr.GoPath)
+ panic("crapnuts")
+ }
+
+ /*
+ log.Info(forgepb.RepoHeader())
+ loop := repos.SortByPath() // get the list of repos
+ for loop.Scan() {
+ r := loop.Repo()
+ log.Info("repo:", r.GoPath)
+ }
+ */
+ /*
+ log.Info("going to add a new repo", argv.GoPath)
+ new1 := forgepb.Repo{
+ GoPath: argv.GoPath,
+ Writable: argv.Writable,
+ ReadOnly: argv.ReadOnly,
+ Private: argv.Private,
+ Directory: argv.Directory,
+ Favorite: argv.Favorite,
+ Interesting: argv.Interesting,
+ }
+ */
+ os.Exit(0)
+}
diff --git a/validate/Makefile b/validate/Makefile
new file mode 100644
index 0000000..1e51eb6
--- /dev/null
+++ b/validate/Makefile
@@ -0,0 +1,21 @@
+VERSION = $(shell git describe --tags)
+BUILDTIME = $(shell date +%Y.%m.%d)
+
+build:
+ GO111MODULE=off go build \
+ -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
+
+test:
+ ./validate --repo go.wit.com/apps/wit-package
+
+goimports:
+ goimports -w *.go
+
+prep:
+ go get -v -t -u
+
+run:
+ go run *.go
+
+clean:
+ -rm -f scanGoSrc
diff --git a/validate/argv.go b/validate/argv.go
new file mode 100644
index 0000000..35dd9a9
--- /dev/null
+++ b/validate/argv.go
@@ -0,0 +1,42 @@
+package main
+
+import (
+ "os"
+
+ "go.wit.com/dev/alexflint/arg"
+)
+
+var argv args
+
+type args struct {
+ Repo string `arg:"--repo" help:"repo to check"`
+ List bool `arg:"--list" default:"false" help:"list repos in your config"`
+ SaveConfig bool `arg:"--save" default:"false" help:"save your config file at the end"`
+ Interesting bool `arg:"--interesting" default:"false" help:"something you decided was cool"`
+}
+
+func (a args) Description() string {
+ return `
+ forgeConfig -- add entries to your config files
+
+This is just example protobuf code to test forgepb is working
+but it could be used to automagically create a config file too.
+
+If you need to change your config file, just edit the forge.text or forge.json
+files then remove the forge.pb and ConfigLoad() will attempt to load those files instead
+`
+}
+
+func (args) Version() string {
+ return "virtigo " + VERSION
+}
+
+func init() {
+ var pp *arg.Parser
+ pp = arg.MustParse(&argv)
+
+ if pp == nil {
+ pp.WriteHelp(os.Stdout)
+ os.Exit(0)
+ }
+}
diff --git a/validate/main.go b/validate/main.go
new file mode 100644
index 0000000..7c32ac6
--- /dev/null
+++ b/validate/main.go
@@ -0,0 +1,97 @@
+package main
+
+import (
+ "fmt"
+ "os"
+
+ "go.wit.com/dev/alexflint/arg"
+ "go.wit.com/gui"
+ "go.wit.com/lib/gui/repolist"
+ "go.wit.com/lib/protobuf/forgepb"
+ "go.wit.com/lib/protobuf/gitpb"
+ "go.wit.com/log"
+)
+
+// sent via ldflags
+var VERSION string
+
+var pp *arg.Parser
+var forge *forgepb.Forge
+var myGui *gui.Node
+var rv *repolist.RepoList
+var argvRepo *gitpb.Repo
+
+func main() {
+ pp = arg.MustParse(&argv)
+
+ // load the ~/.config/forge/ config
+ forge = forgepb.Init()
+ // forge.ConfigPrintTable()
+ os.Setenv("REPO_WORK_PATH", forge.GetGoSrc())
+
+ myGui = gui.New()
+ myGui.Default()
+
+ repos := forge.Repos.SortByGoPath()
+ for repos.Scan() {
+ repo := repos.Next()
+ if ! repo.IsValid() {
+ continue
+ }
+ // forge.VerifyBranchNames(repo)
+ fullpath := repo.GetFullPath()
+ mName := repo.GetMasterBranchName()
+ dName := repo.GetDevelBranchName()
+ uName := repo.GetUserBranchName()
+ dlen := repo.GoDepsLen()
+ plen := repo.PublishedLen()
+ var ds, ps string
+ if dlen == 0 {
+ ds = " "
+ } else {
+ ds = fmt.Sprintf("%2d", dlen)
+ }
+ if plen == 0 {
+ ps = " "
+ } else {
+ ps = fmt.Sprintf("%2d", plen)
+ }
+ log.Printf("repo: %-60s %-10s %-8s %-8s %s %s %s\n", fullpath, mName, dName, uName, ds, ps, repo.RepoType())
+ /*
+ if repo.GoDepsChanged() {
+ log.Printf("\tdependancy checks indicate a new release is needed for %s\n", repo.GetGoPath())
+ } else {
+ log.Printf("\tdependancies have not changed for %s\n", repo.GetGoPath())
+ }
+ */
+ }
+
+ if argv.Repo == "" {
+ log.Info("no --repo")
+ os.Exit(-1)
+ }
+
+ check := forge.Repos.FindByGoPath(argv.Repo)
+ if check == nil {
+ log.Info("boo, you didn't git check", argv.Repo)
+ os.Exit(-1)
+ }
+ check.RedoGoMod()
+
+ match, err := forge.Repos.GoDepsChanged(check)
+ if err != nil {
+ log.Info("dependancy checks failed", check.GetGoPath(), err)
+ os.Exit(-1)
+ }
+ if match {
+ log.Printf("dependancy checks indicate a new release is needed for %s\n", check.GetGoPath())
+ } else {
+ log.Printf("dependancies have not changed for %s\n", check.GetGoPath())
+ }
+
+ if argv.SaveConfig {
+ forge.Repos.ConfigSave()
+ }
+
+ os.Exit(0)
+}
diff --git a/virtbuf-example/Makefile b/virtbuf-example/Makefile
new file mode 100644
index 0000000..57f626f
--- /dev/null
+++ b/virtbuf-example/Makefile
@@ -0,0 +1,17 @@
+build:
+ GO111MODULE=off go build
+
+test:
+ ./virtbuf-example
+
+goimports:
+ goimports -w *.go
+
+prep:
+ go get -v -t -u
+
+run:
+ go run *.go
+
+clean:
+ -rm -f virtbuf-example
diff --git a/virtbuf-example/main.go b/virtbuf-example/main.go
new file mode 100644
index 0000000..fb481ce
--- /dev/null
+++ b/virtbuf-example/main.go
@@ -0,0 +1,91 @@
+package main
+
+import (
+ "fmt"
+ "os"
+
+ pb "go.wit.com/lib/protobuf/virtbuf"
+)
+
+//
+// saves entries in a config file
+//
+
+func main() {
+ TestWriteCluster()
+
+ var c *pb.Cluster
+ c = pb.InitCluster()
+
+ // log.Println(aCluster.String())
+ // show the droplets to STDOUT
+ loop := c.DropletsAll() // get the list of droplets
+ for loop.Scan() {
+ d := loop.Next()
+ fmt.Println("\tdroplet =", d.Hostname, "preffered host:", d.PreferredHypervisor)
+ }
+
+ /*
+ // show the hypervisors to STDOUT
+ for _, h := range aCluster.Hypervisors {
+ fmt.Println("\thypervisor =", h.Hostname, h.GetMemoryPrintable())
+ }
+ */
+
+ /*
+ json := aCluster.FormatJSON()
+ fmt.Println(json)
+
+ data, _ := aCluster.MarshalJSON()
+ fmt.Println(string(data))
+
+ text := aCluster.FormatTEXT()
+ fmt.Println(text)
+ */
+}
+
+/*
+func marshalWriteToFile(myWriter *bufio.Writer, c *pb.Cluster) {
+ buf, err := proto.Marshal(c)
+ if err != nil {
+ log.Fatal("marshaling error: ", err)
+ }
+ tmp, err := myWriter.Write(buf)
+ myWriter.Flush()
+ log.Println("bufio.Write() tmp, err = ", tmp, err)
+
+ buf, err = proto.Marshal(c)
+ tmp2, err := myWriter.Write(buf)
+ myWriter.Flush()
+ log.Println("bufio.Write() tmp2, err = ", tmp2, err)
+}
+*/
+
+func TestWriteCluster() {
+ c := pb.CreateSampleCluster(7)
+ os.Setenv("VIRTIGO_HOME", "/tmp/virtigo/")
+
+ if err := c.ConfigSave(); err != nil {
+ fmt.Println("configsave error", err)
+ os.Exit(-1)
+ }
+ // marshalUnmarshal()
+}
+
+/*
+func marshalUnmarshal() {
+ test := pb.CreateSampleCluster(7)
+ data, err := proto.Marshal(test)
+ if err != nil {
+ log.Fatal("marshaling error: ", err)
+ }
+
+ newTest := &pb.Cluster{}
+ err = proto.Unmarshal(data, newTest)
+ if err != nil {
+ log.Fatal("unmarshaling error: ", err)
+ } else {
+ log.Println("proto.Marshal() and proto.Unmarshal() worked")
+ }
+}
+*/
diff --git a/zoopb-example/Makefile b/zoopb-example/Makefile
new file mode 100644
index 0000000..fe53a86
--- /dev/null
+++ b/zoopb-example/Makefile
@@ -0,0 +1,17 @@
+build:
+ GO111MODULE=off go build
+
+test:
+ ./zoopb-example
+
+goimports:
+ goimports -w *.go
+
+prep:
+ go get -v -t -u
+
+run:
+ go run *.go
+
+clean:
+ -rm -f zoopb-example
diff --git a/zoopb-example/main.go b/zoopb-example/main.go
new file mode 100644
index 0000000..c7d6144
--- /dev/null
+++ b/zoopb-example/main.go
@@ -0,0 +1,71 @@
+package main
+
+import (
+ "fmt"
+
+ "go.wit.com/lib/protobuf/zoopb"
+ "go.wit.com/log"
+)
+
+func main() {
+ m := testMachine()
+ testPackages(m)
+
+ loop := m.Packages.SortByName()
+ for loop.Scan() {
+ p := loop.Next()
+ log.Info("installed package:", p.Name, p.Version, p.PkgName)
+ }
+
+ if m.IsInstalled("bash") {
+ log.Info("bash installed check worked")
+ } else {
+ log.Info("bash installed check failed")
+ panic("bash")
+ }
+
+ if m.IsInstalled("foo") {
+ log.Info("foo not-installed check failed")
+ panic("foo")
+ } else {
+ log.Info("foo not-installed check worked")
+ }
+}
+
+func testMachine() *zoopb.Machine {
+ var m *zoopb.Machine
+ m = new(zoopb.Machine)
+ m.Hostname = "zookeeper"
+ return m
+}
+
+func testPackages(m *zoopb.Machine) {
+ m.Packages = new(zoopb.Packages)
+ // r = zoopb.LoadJSON("go.wit.com/lib/protobuf/zoopb")
+
+ new1 := new(zoopb.Package)
+ new1.Name = "bash"
+ new1.Version = "5.2.21"
+ if m.Packages.Append(new1) {
+ log.Info("added", new1.Name, "ok")
+ } else {
+ log.Info("added", new1.Name, "failed")
+ }
+
+ new2 := new(zoopb.Package)
+ new2.Name = "go-clone"
+ new2.Version = "0.6.8" // good version of the macos
+ if m.Packages.Append(new2) {
+ log.Info("added", new2.Name, "ok")
+ } else {
+ log.Info("added", new2.Name, "failed")
+ }
+
+ if m.Packages.Append(new2) {
+ log.Info("added", new2.Name, "ok (this is bad)")
+ } else {
+ log.Info("added", new2.Name, "failed (but ok)")
+ }
+
+ fmt.Println("package count = ", m.Packages.Len())
+}