From b857c6c6028e3576c1975e2486a3969b0a9acf46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 26 Dec 2024 12:36:03 +0000 Subject: [PATCH] update testscript to drop func() int --- cmd/xurls/main.go | 15 ++++++--------- cmd/xurls/main_test.go | 6 +++--- go.mod | 12 ++++++------ go.sum | 20 ++++++++++---------- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/cmd/xurls/main.go b/cmd/xurls/main.go index 3a56281..bf72e9f 100644 --- a/cmd/xurls/main.go +++ b/cmd/xurls/main.go @@ -211,17 +211,15 @@ func scanPath(re *regexp.Regexp, path string) error { return nil } -func main() { os.Exit(main1()) } - -func main1() int { +func main() { flag.Parse() if *versionFlag { fmt.Println(readVersion()) - return 0 + return } if *relaxed && *matching != "" { fmt.Fprintln(os.Stderr, "-r and -m at the same time don't make much sense") - return 1 + os.Exit(1) } switch fix { case "": // disabled by default @@ -232,7 +230,7 @@ func main1() int { fix = "auto" default: flag.Usage() - return 1 + os.Exit(2) } var re *regexp.Regexp if *relaxed { @@ -241,7 +239,7 @@ func main1() int { var err error if re, err = xurls.StrictMatchingScheme(*matching); err != nil { fmt.Fprintln(os.Stderr, err) - return 1 + os.Exit(2) } } else { re = xurls.Strict() @@ -253,10 +251,9 @@ func main1() int { for _, path := range args { if err := scanPath(re, path); err != nil { fmt.Fprintln(os.Stderr, err) - return 1 + os.Exit(1) } } - return 0 } // Borrowed from https://github.com/burrowers/garble. diff --git a/cmd/xurls/main_test.go b/cmd/xurls/main_test.go index 6113cee..8e061ad 100644 --- a/cmd/xurls/main_test.go +++ b/cmd/xurls/main_test.go @@ -16,9 +16,9 @@ import ( ) func TestMain(m *testing.M) { - os.Exit(testscript.RunMain(m, map[string]func() int{ - "xurls": main1, - })) + testscript.Main(m, map[string]func(){ + "xurls": main, + }) } func TestScript(t *testing.T) { diff --git a/go.mod b/go.mod index f1745d1..353aa56 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,14 @@ module mvdan.cc/xurls/v2 -go 1.22 +go 1.22.0 require ( - github.com/rogpeppe/go-internal v1.12.0 - golang.org/x/mod v0.16.0 - golang.org/x/sync v0.6.0 + github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a + golang.org/x/mod v0.21.0 + golang.org/x/sync v0.8.0 ) require ( - golang.org/x/sys v0.18.0 // indirect - golang.org/x/tools v0.19.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/tools v0.26.0 // indirect ) diff --git a/go.sum b/go.sum index 4fdb9c0..3959cf0 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,10 @@ -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= -golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= -golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= -golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= +github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a h1:w3tdWGKbLGBPtR/8/oO74W6hmz0qE5q0z9aqSAewaaM= +github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a/go.mod h1:S8kfXMp+yh77OxPD4fdM6YUknrZpQxLhvxzS4gDHENY= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= +golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=