summaryrefslogtreecommitdiff
path: root/goList.go
blob: b49ecd25e61984f17aa312cbbb0aeb2aa16bb7b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package repostatus

import (
	"encoding/json"
	"errors"

	"go.wit.com/lib/gui/shell"
	"go.wit.com/log"
)

// go list -json -m go.wit.com/apps/go-clone@latest

// go list -json -m go.wit.com/apps/go-clone@latest
// {
// 	"Path": "go.wit.com/apps/go-clone",
// 	"Version": "v0.0.6",
// 	"Query": "latest",
// 	"Time": "2024-03-10T04:12:15Z",
// 	"GoMod": "/home/jcarr/go/pkg/mod/cache/download/go.wit.com/apps/go-clone/@v/v0.0.6.mod",
// 	"GoVersion": "1.22.0"
// }

func runGoList(url string) (string, error) {
	r := shell.RunPath("", []string{"go", "list", "-json", "-m", url + "@latest"})
	log.Info("runGoList() r.Output =", r.Output)
	var modInfo any
	err := json.Unmarshal(r.Output, &modInfo)
	if err != nil {
		log.Info("runGoList() json.Unmarshal() error =", err)
		return "", err
	}
	log.Spew(modInfo)
	return "", errors.New("todo: parse json")
}