chore(gui): use go list --deps for dependency list (#10071)

This commit is contained in:
Ross Smith II
2025-04-25 19:24:31 -07:00
committed by GitHub
parent 190dff142c
commit 93e72cc83f
2 changed files with 49 additions and 71 deletions

View File

@@ -51,81 +51,57 @@ Jakob Borg, Audrius Butkevicius, Jesse Lucas, Simon Frei, Tomasz Wilczyński, Al
<li><a href="https://golang.org/">The Go Programming Language</a>, Copyright &copy; 2009 The Go Authors.</li>
<li><a href="https://prometheus.io/">Prometheus</a>, Copyright &copy; 2012-2015 The Prometheus Authors.</li>
<li><a href="https://github.com/AudriusButkevicius/recli">AudriusButkevicius/recli</a>, Copyright &copy; 2019 Audrius Butkevicius.</li>
<li><a href="https://github.com/Azure/azure-sdk-for-go">Azure/azure-sdk-for-go</a>, Copyright &copy; Microsoft Corporation.</li>
<li><a href="https://github.com/Azure/go-ntlmssp">Azure/go-ntlmssp</a>, Copyright &copy; 2016 Microsoft.</li>
<li><a href="https://github.com/alecthomas/kong">alecthomas/kong</a>, Copyright &copy; 2018 Alec Thomas.</li>
<li><a href="https://github.com/aws/aws-sdk-go">aws/aws-sdk-go</a>, Copyright &copy; 2015 Amazon.com, Inc. or its affiliates, Copyright 2014-2015 Stripe, Inc.</li>
<li><a href="https://github.com/beorn7/perks">beorn7/perks</a>, Copyright &copy; 2013 Blake Mizerany.</li>
<li><a href="https://github.com/calmh/incontainer">calmh/incontainer</a>, Copyright &copy; 2022 calmh.</li>
<li><a href="https://github.com/calmh/xdr">calmh/xdr</a>, Copyright &copy; 2014 Jakob Borg.</li>
<li><a href="https://github.com/ccding/go-stun">ccding/go-stun</a>, Copyright &copy; 2016 Cong Ding.</li>
<li><a href="https://github.com/cenkalti/backoff">cenkalti/backoff</a>, Copyright &copy; 2014 Cenk Altı.</li>
<li><a href="https://github.com/certifi/gocertifi">certifi/gocertifi</a>, Copyright &copy; 2025, the certifi/gocertifi authors.</li>
<li><a href="https://github.com/cespare/xxhash">cespare/xxhash</a>, Copyright &copy; 2016 Caleb Spare.</li>
<li><a href="https://github.com/cespare/xxhash/v2">cespare/xxhash/v2</a>, Copyright &copy; 2016 Caleb Spare.</li>
<li><a href="https://github.com/chmduquesne/rollinghash">chmduquesne/rollinghash</a>, Copyright &copy; 2015 Christophe-Marie Duquesne.</li>
<li><a href="https://github.com/cpuguy83/go-md2man">cpuguy83/go-md2man</a>, Copyright &copy; 2014 Brian Goff.</li>
<li><a href="https://github.com/d4l3k/messagediff">d4l3k/messagediff</a>, Copyright &copy; 2015 Tristan Rice.</li>
<li><a href="https://github.com/davecgh/go-spew">davecgh/go-spew</a>, Copyright &copy; 2012-2016 Dave Collins <dave@davec.name>.</li>
<li><a href="https://github.com/cpuguy83/go-md2man/v2">cpuguy83/go-md2man/v2</a>, Copyright &copy; 2014 Brian Goff.</li>
<li><a href="https://github.com/davecgh/go-spew">davecgh/go-spew</a>, Copyright &copy; 2012-2016 Dave Collins.</li>
<li><a href="https://github.com/ebitengine/purego">ebitengine/purego</a>, Copyright &copy; 2022 The Ebitengine Authors.</li>
<li><a href="https://github.com/fsnotify/fsnotify">fsnotify/fsnotify</a>, Copyright &copy; 2012 The Go Authors.</li>
<li><a href="https://github.com/getsentry/raven-go">getsentry/raven-go</a>, Copyright &copy; 2013 Apollic Software, LLC.</li>
<li><a href="https://github.com/go-asn1-ber/asn1-ber">go-asn1-ber/asn1-ber</a>, Copyright &copy; 2011-2015 Michael Mitton (mmitton@gmail.com).</li>
<li><a href="https://github.com/go-ldap/ldap">go-ldap/ldap</a>, Copyright &copy; 2011-2015 Michael Mitton (mmitton@gmail.com).</li>
<li><a href="https://github.com/go-ole/go-ole">go-ole/go-ole</a>, Copyright &copy; 2013-2017 Yasuhiro Matsumoto, <mattn.jp@gmail.com>.</li>
<li><a href="https://github.com/go-task/slim-sprig">go-task/slim-sprig</a>, Copyright &copy; 2013-2020 Masterminds.</li>
<li><a href="https://github.com/uber-go/automaxprocs">go.uber.org/automaxprocs</a>, Copyright &copy; 2017 Uber Technologies, Inc.</li>
<li><a href="https://github.com/uber-go/mock">go.uber.org/mock</a>, Copyright &copy; 2010-2022 Google LLC.</li>
<li><a href="https://github.com/gobwas/glob">gobwas/glob</a>, Copyright &copy; 2016 Sergey Kamardin.</li>
<li><a href="https://github.com/gofrs/flock">gofrs/flock</a>, Copyright &copy; 2018-2025, The Gofrs.</li>
<li><a href="https://github.com/golang/snappy">golang/snappy</a>, Copyright &copy; 2011 The Snappy-Go Authors.</li>
<li><a href="https://github.com/protocolbuffers/protobuf-go">google.golang.org/protobuf</a>, Copyright &copy; 2018 The Go Authors.</li>
<li><a href="https://github.com/google/pprof">google/pprof</a>, Copyright &copy; 2016 Google Inc.</li>
<li><a href="https://github.com/google/uuid">google/uuid</a>, Copyright &copy; 2009,2014 Google Inc.</li>
<li><a href="https://github.com/go-yaml/yaml">gopkg.in/yaml.v3</a>, Copyright &copy; 2006-2010 Kirill Simonov.</li>
<li><a href="https://gopkg.in/yaml.v3">gopkg.in/yaml.v3</a>, Copyright &copy; 2025, the gopkg.in/yaml.v3 authors.</li>
<li><a href="https://github.com/greatroar/blobloom">greatroar/blobloom</a>, Copyright &copy; 2020-2024 the Blobloom authors.</li>
<li><a href="https://github.com/hashicorp/errwrap">hashicorp/errwrap</a>, Copyright &copy; 2014 HashiCorp, Inc.</li>
<li><a href="https://github.com/hashicorp/go-multierror">hashicorp/go-multierror</a>, Copyright &copy; 2014 HashiCorp, Inc.</li>
<li><a href="https://github.com/hashicorp/golang-lru">hashicorp/golang-lru</a>, Copyright &copy; 2014 HashiCorp, Inc.</li>
<li><a href="https://github.com/jackpal/gateway">jackpal/gateway</a>, Copyright &copy; 2010 Jack Palevich.</li>
<li><a href="https://github.com/jackpal/go-nat-pmp">jackpal/go-nat-pmp</a>, Copyright 2013 John Howard Palevich.</li>
<li><a href="https://github.com/jmespath/go-jmespath">jmespath/go-jmespath</a>, Copyright &copy; 2015 James Saryerwinnie.</li>
<li><a href="https://github.com/julienschmidt/httprouter">julienschmidt/httprouter</a>, Copyright &copy; 2013, Julien Schmidt.</li>
<li><a href="https://github.com/kballard/go-shellquote">kballard/go-shellquote</a>, Copyright &copy; 2014 Kevin Ballard.</li>
<li><a href="https://github.com/klauspost/compress">klauspost/compress</a>, Copyright &copy; 2012 The Go Authors.</li>
<li><a href="https://github.com/lufia/plan9stats">lufia/plan9stats</a>, Copyright &copy; 2019, KADOTA, Kyohei.</li>
<li><a href="https://github.com/maruel/panicparse">maruel/panicparse</a>, Copyright 2015 Marc-Antoine Ruel.</li>
<li><a href="https://github.com/maxbrunsfeld/counterfeiter">maxbrunsfeld/counterfeiter</a>, Copyright &copy; 2014 maxbrunsfeld.</li>
<li><a href="https://github.com/maxmind/geoipupdate">maxmind/geoipupdate</a>, Copyright &copy; 2018-2024 by MaxMind, Inc.</li>
<li><a href="https://github.com/miscreant/miscreant.go">miscreant/miscreant.go</a>, Copyright &copy; 2017-2019 The Miscreant Developers.</li>
<li><a href="https://github.com/munnerz/goautoneg">munnerz/goautoneg</a>, Copyright &copy; 2011, Open Knowledge Foundation Ltd.</li>
<li><a href="https://github.com/nxadm/tail">nxadm/tail</a>, Copyright &copy; 2014 ActiveState.</li>
<li><a href="https://github.com/onsi/ginkgo">onsi/ginkgo</a>, Copyright &copy; 2013-2014 Onsi Fakhouri.</li>
<li><a href="https://github.com/oschwald/geoip2-golang">oschwald/geoip2-golang</a>, Copyright &copy; 2015, Gregory J. Oschwald.</li>
<li><a href="https://github.com/oschwald/maxminddb-golang">oschwald/maxminddb-golang</a>, Copyright &copy; 2015, Gregory J. Oschwald.</li>
<li><a href="https://github.com/pierrec/lz4">pierrec/lz4</a>, Copyright &copy; 2015 Pierre Curto.</li>
<li><a href="https://github.com/pkg/errors">pkg/errors</a>, Copyright &copy; 2015, Dave Cheney.</li>
<li><a href="https://github.com/pmezard/go-difflib">pmezard/go-difflib</a>, Copyright &copy; 2013, Patrick Mezard.</li>
<li><a href="https://github.com/posener/complete">posener/complete</a>, Copyright &copy; 2017 Eyal Posener.</li>
<li><a href="https://github.com/power-devops/perfstat">power-devops/perfstat</a>, Copyright &copy; 2020 Power DevOps.</li>
<li><a href="https://github.com/puzpuzpuz/xsync">puzpuzpuz/xsync</a>, Copyright &copy; 2025, the puzpuzpuz/xsync authors.</li>
<li><a href="https://github.com/prometheus/client_golang">prometheus/client_golang</a>, Copyright 2012-2015 The Prometheus Authors.</li>
<li><a href="https://github.com/prometheus/client_model">prometheus/client_model</a>, Copyright &copy; 2025, the prometheus/client_model authors.</li>
<li><a href="https://github.com/prometheus/common">prometheus/common</a>, Copyright &copy; 2025, the prometheus/common authors.</li>
<li><a href="https://github.com/quic-go/quic-go">quic-go/quic-go</a>, Copyright &copy; 2016 the quic-go authors & Google, Inc.</li>
<li><a href="https://github.com/rabbitmq/amqp091-go">rabbitmq/amqp091-go</a>, Copyright &copy; 2021 VMware, Inc. or its affiliates.</li>
<li><a href="https://github.com/rcrowley/go-metrics">rcrowley/go-metrics</a>, Copyright &copy; 2012 Richard Crowley.</li>
<li><a href="https://github.com/riywo/loginshell">riywo/loginshell</a>, Copyright &copy; 2019 Ryosuke IWANAGA.</li>
<li><a href="https://github.com/russross/blackfriday">russross/blackfriday</a>, Copyright &copy; 2011 Russ Ross.</li>
<li><a href="https://github.com/russross/blackfriday/v2">russross/blackfriday/v2</a>, Copyright &copy; 2011 Russ Ross.</li>
<li><a href="https://github.com/shirou/gopsutil">shirou/gopsutil</a>, Copyright &copy; 2014, WAKAYAMA Shirou.</li>
<li><a href="https://github.com/kubernetes-sigs/yaml">sigs.k8s.io/yaml</a>, Copyright &copy; 2014 Sam Ghods.</li>
<li><a href="https://github.com/stretchr/objx">stretchr/objx</a>, Copyright &copy; 2014 Stretchr, Inc.</li>
<li><a href="https://github.com/stretchr/testify">stretchr/testify</a>, Copyright &copy; 2012-2020 Mat Ryer, Tyler Bunnell and contributors.</li>
<li><a href="https://github.com/syncthing/notify">syncthing/notify</a>, Copyright &copy; 2014-2015 The Notify Authors.</li>
<li><a href="https://github.com/syndtr/goleveldb">syndtr/goleveldb</a>, Copyright &copy; 2012 Suryandaru Triandana.</li>
<li><a href="https://github.com/thejerf/suture">thejerf/suture</a>, Copyright &copy; 2014-2015 Barracuda Networks, Inc.</li>
<li><a href="https://github.com/tklauser/go-sysconf">tklauser/go-sysconf</a>, Copyright &copy; 2018-2022, Tobias Klauser.</li>
<li><a href="https://github.com/tklauser/numcpus">tklauser/numcpus</a>, Copyright &copy; 2018-2024 Tobias Klauser.</li>
<li><a href="https://github.com/urfave/cli">urfave/cli</a>, Copyright &copy; 2016 Jeremy Saenz & Contributors.</li>
<li><a href="https://github.com/vitrun/qart">vitrun/qart</a>, Copyright &copy; 2010-2011 The Go Authors.</li>
<li><a href="https://github.com/willabides/kongplete">willabides/kongplete</a>, Copyright &copy; 2020 WillAbides.</li>
<li><a href="https://github.com/yusufpapurcu/wmi">yusufpapurcu/wmi</a>, Copyright &copy; 2013 Stack Exchange.</li>
</ul>
</div>

View File

@@ -13,8 +13,6 @@
package main
import (
"bufio"
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
@@ -50,6 +48,8 @@ var copyrightMap = map[string]string{
"jmespath/go-jmespath": "Copyright &copy; 2015 James Saryerwinnie",
// https://github.com/maxmind/geoipupdate/blob/main/README.md?plain=1#L140
"maxmind/geoipupdate": "Copyright &copy; 2018-2024 by MaxMind, Inc",
// https://github.com/search?q=repo%3Aprometheus%2Fclient_golang%20copyright&type=code
"prometheus/client_golang": "Copyright 2012-2015 The Prometheus Authors",
// https://github.com/search?q=repo%3Apuzpuzpuz%2Fxsync%20copyright&type=code
// "puzpuzpuz/xsync": "No copyrights found",
// https://github.com/search?q=repo%3Atklauser%2Fnumcpus%20copyright&type=code
@@ -61,10 +61,10 @@ var copyrightMap = map[string]string{
var urlMap = map[string]string{
"fontawesome.io": "https://github.com/FortAwesome/Font-Awesome",
"go.uber.org/automaxprocs": "https://github.com/uber-go/automaxprocs",
"go.uber.org/mock": "https://github.com/uber-go/mock",
// "go.uber.org/mock": "https://github.com/uber-go/mock",
"google.golang.org/protobuf": "https://github.com/protocolbuffers/protobuf-go",
"gopkg.in/yaml.v2": "", // ignore, as gopkg.in/yaml.v3 supersedes
"gopkg.in/yaml.v3": "https://github.com/go-yaml/yaml",
// "gopkg.in/yaml.v2": "", // ignore, as gopkg.in/yaml.v3 supersedes
// "gopkg.in/yaml.v3": "https://github.com/go-yaml/yaml",
"sigs.k8s.io/yaml": "https://github.com/kubernetes-sigs/yaml",
}
@@ -174,6 +174,7 @@ func main() {
if n.Type != TypeNew {
continue
}
copyright, ok := copyrightMap[n.Name]
if ok {
notices[i].Copyright = copyright
@@ -272,44 +273,43 @@ func writeFile(path string, data string) {
}
func getModules() []string {
cmd := exec.Command("go", "mod", "graph")
output, err := cmd.Output()
ignoreRe := regexp.MustCompile(`golang\.org/x/|github\.com/syncthing|^[^.]+(/|$)`)
// List all modules (used for mapping packages to modules)
data, err := exec.Command("go", "list", "-m", "all").Output()
if err != nil {
log.Fatal(err)
log.Fatalf("go list -m all: %v", err)
}
modules := strings.Split(string(data), "\n")
for i := range modules {
modules[i], _, _ = strings.Cut(modules[i], " ")
}
modules = slices.DeleteFunc(modules, func(s string) bool { return s == "" })
// List all packages in use by the syncthing binary, map them to modules
data, err = exec.Command("go", "list", "-deps", "./cmd/syncthing").Output()
if err != nil {
log.Fatalf("go list -deps ./cmd/syncthing: %v", err)
}
packages := strings.Split(string(data), "\n")
packages = slices.DeleteFunc(packages, func(s string) bool { return s == "" })
seen := make(map[string]struct{})
scanner := bufio.NewScanner(bytes.NewReader(output))
for scanner.Scan() {
line := scanner.Text()
fields := strings.Fields(line)
if len(fields) == 0 {
for _, pkg := range packages {
if ignoreRe.MatchString(pkg) {
continue
}
if !strings.HasPrefix(fields[0], "github.com/syncthing/syncthing") {
// Find module for package
modIdx := slices.IndexFunc(modules, func(mod string) bool {
return strings.HasPrefix(pkg, mod)
})
if modIdx < 0 {
log.Println("no module for", pkg)
continue
}
// Get left-hand side of dependency pair (before '@')
mod := strings.SplitN(fields[1], "@", 2)[0]
// Keep only first 3 path components
parts := strings.Split(mod, "/")
if len(parts) == 1 {
continue
}
short := strings.Join(parts[:min(len(parts), 3)], "/")
if strings.HasPrefix(short, "golang.org/x") ||
strings.HasPrefix(short, "github.com/prometheus") ||
short == "go" {
continue
}
seen[short] = struct{}{}
module := modules[modIdx]
seen[module] = struct{}{}
}
adds := make([]string, 0)
@@ -404,7 +404,9 @@ func getLicenseText(owner, repo string) string {
log.Fatal(err)
}
defer resp.Body.Close()
if resp.StatusCode == 404 {
return ""
}
var result struct {
Content string `json:"content"`
Encoding string `json:"encoding"`
@@ -416,7 +418,7 @@ func getLicenseText(owner, repo string) string {
}
if result.Encoding != "base64" {
log.Fatal(fmt.Sprintf("unexpected encoding: %s", result.Encoding))
log.Fatal(fmt.Sprintf("unexpected encoding: %q", result.Encoding))
}
decoded, err := base64.StdEncoding.DecodeString(result.Content)