Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bcdf84a

Browse files
committed
gocritic clean
1 parent 590571b commit bcdf84a

File tree

4 files changed

+24
-42
lines changed

4 files changed

+24
-42
lines changed

‎go.mod‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
module github.com/bitfield/script
22

3-
go 1.12
3+
go 1.18
44

55
require (
66
github.com/google/go-cmp v0.5.9
77
github.com/itchyny/gojq v0.12.12
88
github.com/rogpeppe/go-internal v1.10.0
99
mvdan.cc/sh/v3 v3.6.0
1010
)
11+
12+
require github.com/itchyny/timefmt-go v0.1.5 // indirect

‎go.sum‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,13 @@
1-
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
2-
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
31
github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
4-
github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
5-
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
62
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
73
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
8-
github.com/google/renameio/v2 v2.0.0/go.mod h1:BtmJXm5YlszgC+TD4HOEEUFgkJP3nLxehU6hfe7jRt4=
94
github.com/itchyny/gojq v0.12.12 h1:x+xGI9BXqKoJQZkr95ibpe3cdrTbY8D9lonrK433rcA=
105
github.com/itchyny/gojq v0.12.12/go.mod h1:j+3sVkjxwd7A7Z5jrbKibgOLn0ZfLWkV+Awxr/pyzJE=
116
github.com/itchyny/timefmt-go v0.1.5 h1:G0INE2la8S6ru/ZI5JecgyzbbJNs5lG1RcBqa7Jm6GE=
127
github.com/itchyny/timefmt-go v0.1.5/go.mod h1:nEP7L+2YmAbT2kZ2HfSs1d8Xtw9LY8D2stDBckWakZ8=
138
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
14-
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
159
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
16-
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
17-
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
18-
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
19-
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
20-
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
21-
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
22-
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
2310
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
2411
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
25-
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
26-
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
27-
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
28-
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
29-
golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA=
30-
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
31-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
32-
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
33-
mvdan.cc/editorconfig v0.2.0/go.mod h1:lvnnD3BNdBYkhq+B4uBuFFKatfp02eB6HixDvEz91C0=
3412
mvdan.cc/sh/v3 v3.6.0 h1:gtva4EXJ0dFNvl5bHjcUEvws+KRcDslT8VKheTYkbGU=
3513
mvdan.cc/sh/v3 v3.6.0/go.mod h1:U4mhtBLZ32iWhif5/lD+ygy1zrgaQhUu+XFy7C8+TTA=

‎script.go‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ func FindFiles(dir string) *Pipe {
104104
return Slice(paths)
105105
}
106106

107-
// Get creates a pipe that makes an HTTP GET request to URL, and produces the
107+
// Get creates a pipe that makes an HTTP GET request to url, and produces the
108108
// response. See [Pipe.Do] for how the HTTP response status is interpreted.
109-
func Get(URL string) *Pipe {
110-
return NewPipe().Get(URL)
109+
func Get(url string) *Pipe {
110+
return NewPipe().Get(url)
111111
}
112112

113113
// IfExists tests whether path exists, and creates a pipe whose error status
@@ -169,11 +169,11 @@ func NewPipe() *Pipe {
169169
}
170170
}
171171

172-
// Post creates a pipe that makes an HTTP POST request to URL, with an empty
172+
// Post creates a pipe that makes an HTTP POST request to url, with an empty
173173
// body, and produces the response. See [Pipe.Do] for how the HTTP response
174174
// status is interpreted.
175-
func Post(URL string) *Pipe {
176-
return NewPipe().Post(URL)
175+
func Post(url string) *Pipe {
176+
return NewPipe().Post(url)
177177
}
178178

179179
// Slice creates a pipe containing each element of s, one per line.
@@ -584,11 +584,11 @@ func (p *Pipe) Freq() *Pipe {
584584
})
585585
}
586586

587-
// Get makes an HTTP GET request to URL, sending the contents of the pipe as
587+
// Get makes an HTTP GET request to url, sending the contents of the pipe as
588588
// the request body, and produces the server's response. See [Pipe.Do] for how
589589
// the HTTP response status is interpreted.
590-
func (p *Pipe) Get(URL string) *Pipe {
591-
req, err := http.NewRequest(http.MethodGet, URL, p.Reader)
590+
func (p *Pipe) Get(url string) *Pipe {
591+
req, err := http.NewRequest(http.MethodGet, url, p.Reader)
592592
if err != nil {
593593
return p.WithError(err)
594594
}
@@ -693,11 +693,11 @@ func (p *Pipe) MatchRegexp(re *regexp.Regexp) *Pipe {
693693
})
694694
}
695695

696-
// Post makes an HTTP POST request to URL, using the contents of the pipe as
696+
// Post makes an HTTP POST request to url, using the contents of the pipe as
697697
// the request body, and produces the server's response. See [Pipe.Do] for how
698698
// the HTTP response status is interpreted.
699-
func (p *Pipe) Post(URL string) *Pipe {
700-
req, err := http.NewRequest(http.MethodPost, URL, p.Reader)
699+
func (p *Pipe) Post(url string) *Pipe {
700+
req, err := http.NewRequest(http.MethodPost, url, p.Reader)
701701
if err != nil {
702702
return p.WithError(err)
703703
}
@@ -905,7 +905,7 @@ func (p *Pipe) writeOrAppendFile(path string, mode int) (int64, error) {
905905
if p.Error() != nil {
906906
return 0, p.Error()
907907
}
908-
out, err := os.OpenFile(path, mode, 0666)
908+
out, err := os.OpenFile(path, mode, 0o666)
909909
if err != nil {
910910
p.SetError(err)
911911
return 0, err

‎script_test.go‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func TestDoPerformsSuppliedHTTPRequest(t *testing.T) {
244244
fmt.Fprintln(w, "some data")
245245
}))
246246
defer ts.Close()
247-
req, err := http.NewRequest(http.MethodGet, ts.URL, nil)
247+
req, err := http.NewRequest(http.MethodGet, ts.URL, http.NoBody)
248248
if err != nil {
249249
t.Fatal(err)
250250
}
@@ -1669,7 +1669,7 @@ func TestWriteFile_TruncatesExistingFile(t *testing.T) {
16691669
path := t.TempDir() + "/" + t.Name()
16701670
// write some data first so we can check for truncation
16711671
data := make([]byte, 15)
1672-
err := os.WriteFile(path, data, 0600)
1672+
err := os.WriteFile(path, data, 0o600)
16731673
if err != nil {
16741674
t.Fatal(err)
16751675
}
@@ -1698,7 +1698,7 @@ func TestWithHTTPClient_SetsSuppliedClientOnPipe(t *testing.T) {
16981698
fmt.Fprintln(w, "some data")
16991699
}))
17001700
defer ts.Close()
1701-
req, err := http.NewRequest(http.MethodGet, ts.URL, nil)
1701+
req, err := http.NewRequest(http.MethodGet, ts.URL, http.NoBody)
17021702
if err != nil {
17031703
t.Fatal(err)
17041704
}
@@ -1842,9 +1842,10 @@ func ExampleDo() {
18421842
fmt.Fprintln(w, "some data")
18431843
}))
18441844
defer ts.Close()
1845-
req, err := http.NewRequest(http.MethodGet, ts.URL, nil)
1845+
req, err := http.NewRequest(http.MethodGet, ts.URL, http.NoBody)
18461846
if err != nil {
1847-
log.Fatal(err)
1847+
log.Println(err)
1848+
return
18481849
}
18491850
script.Do(req).Stdout()
18501851
// Output:
@@ -1961,7 +1962,8 @@ func ExamplePipe_Do() {
19611962
defer ts.Close()
19621963
req, err := http.NewRequest(http.MethodGet, ts.URL, strings.NewReader("hello"))
19631964
if err != nil {
1964-
log.Fatal(err)
1965+
log.Println(err)
1966+
return
19651967
}
19661968
script.NewPipe().Do(req).Stdout()
19671969
// Output:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /