exposes memory corruption. need to fix

This commit is contained in:
Jeff Carr 2024-11-20 13:43:26 -06:00
parent e14bc69169
commit 09f855910c
3 changed files with 15 additions and 1 deletions

View File

@ -13,6 +13,9 @@ list:
add: add:
./forgeConfig --add --name 'foo' --gopath 'go.wit.com/apps/foo' ./forgeConfig --add --name 'foo' --gopath 'go.wit.com/apps/foo'
update:
./forgeConfig --update --name 'foo' --gopath 'go.wit.com/apps/foonew'
goimports: goimports:
goimports -w *.go goimports -w *.go

View File

@ -12,6 +12,7 @@ type args struct {
ConfigDir string `arg:"env:FORGE_HOME" help:"defaults to ~/.config/forge/"` ConfigDir string `arg:"env:FORGE_HOME" help:"defaults to ~/.config/forge/"`
List bool `arg:"--list" default:"false" help:"list repos in your config"` List bool `arg:"--list" default:"false" help:"list repos in your config"`
Add bool `arg:"--add" default:"false" help:"add a new repo"` Add bool `arg:"--add" default:"false" help:"add a new repo"`
Update bool `arg:"--update" default:"false" help:"update a repo"`
Name string `arg:"--name" help:"name of the repo"` Name string `arg:"--name" help:"name of the repo"`
GoPath string `arg:"--gopath" help:"gopath of the repo"` GoPath string `arg:"--gopath" help:"gopath of the repo"`
} }

View File

@ -20,13 +20,23 @@ func main() {
} }
if argv.List { if argv.List {
log.Info(forgepb.RepoHeader()) log.Info(forgepb.RepoHeader())
loop := repos.SortByName() // get the list of droplets loop := repos.SortByName() // get the list of repos
for loop.Scan() { for loop.Scan() {
r := loop.Repo() r := loop.Repo()
log.Info("repo:", r.Name, r.Gopath) log.Info("repo:", r.Name, r.Gopath)
} }
os.Exit(0) os.Exit(0)
} }
if argv.Update {
r := repos.FindByName(argv.Name) // find the repo
if r == nil {
log.Info("rep:", argv.Name, "not found")
os.Exit(-1)
}
r.Gopath = argv.GoPath
repos.ConfigSave()
os.Exit(0)
}
if argv.Add { if argv.Add {
log.Info("going to add a new repo", argv.Name, argv.GoPath) log.Info("going to add a new repo", argv.Name, argv.GoPath)
new1 := new(forgepb.Repo) new1 := new(forgepb.Repo)