Skip to content
This repository was archived by the owner on Jul 14, 2022. It is now read-only.

Commit e5f4f91

Browse files
authored
Dependencies, go version update, and Makefile fixes (#44)
* update all dependencies and require go1.16 * fixed Makefile: When the deps target was added in November 2020, it became the default make target. When make was called without arguments, it would install stuffbin and exit without building hopp-cli. Added an 'all' target as the default target that installs stuffbin and builds hopp-cli. Cleaned up all of the targets. Changed the deps target to use the idiomatic 'go install' instead of 'go get' to prevent mangling go.mod when installing stuffbin. Removed the 'update' target as it's redundant re: git pull. * updated travis build manifest to use go-1.16.x * changed go.mod path to reflect new repository location it still mentioned the old pwcli repo. also updated cli.go 'methods' import statement to reflect this. * update old references to ioutil package. ioutil is deprecated. ioutil.ReadAll() is deprecated in favor of io.ReadAll() ioutil.ReadFile() is deprecated in favor of os.ReadFile() * wrap errors when bubbling up * hoop.bin was in .gitignore instead of hopp.bin * only install bin dep stuffbin if it isn't already installed Authored by: @gbmor
1 parent 8fc5452 commit e5f4f91

11 files changed

Lines changed: 108 additions & 109 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*.so
1111
*.dylib
1212
hopp-cli
13-
hoop.bin
13+
hopp.bin
1414
dist/
1515

1616
# Test binary, built with `go test -c`

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ sudo: false
22
language: go
33

44
go:
5-
- "1.13"
5+
- "1.16.x"
66
before_script:
77
- go get -v
88
- go build

Makefile

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,41 @@
11
BIN:=hopp.bin
2+
BINSTUFFED:=hopp-cli
23
PREFIX?=/usr/local
34
BINDIR?=$(PREFIX)/bin
45
VERSION?=$(shell git tag | grep ^v | sort -V | tail -n 1)
56
STATIC := ./templates/index.html ./templates/template.md:/template.md
67

8+
all: deps build
9+
10+
.PHONY: deps
711
deps:
8-
go get -u github.com/knadh/stuffbin/...
12+
@printf '%s\n' 'Checking binary dependencies...'
13+
@if [ ! -f "$(shell go env GOPATH)/bin/stuffbin" ]; then printf '%s\n' 'Installing stuffbin to GOPATH' && go install github.com/knadh/stuffbin/stuffbin@latest; fi
914

10-
build: cli.go go.mod go.sum
11-
@echo
12-
@echo Building hopp-cli. This may take a minute or two.
13-
@echo
14-
go build -o ${BIN} -ldflags="-s -w -X 'main.buildVersion=${VERSION}'" *.go
15-
stuffbin -a stuff -in ${BIN} -out ${BIN} ${STATIC}
16-
@echo
17-
@echo ...Done\!
15+
.PHONY: build
16+
build:
17+
@printf '%s\n' 'Building hopp-cli. This may take a minute or two.'
18+
go build -o ${BIN} -ldflags="-s -w -X 'main.buildVersion=${VERSION}'"
19+
$(shell go env GOPATH)/bin/stuffbin -a stuff -in ${BIN} -out ${BINSTUFFED} ${STATIC}
20+
rm ${BIN}
1821

1922
.PHONY: clean
2023
clean:
21-
@echo
22-
@echo Cleaning...
23-
@echo
24-
go clean
25-
@echo
26-
@echo ...Done\!
27-
28-
.PHONY: update
29-
update:
30-
@echo
31-
@echo Updating from upstream repository...
32-
@echo
33-
git pull --rebase origin master
34-
@echo
35-
@echo ...Done\!
24+
@printf '%s\n' 'Cleaning...'
25+
@go clean
26+
@if [ -f 'hopp-cli' ]; then rm hopp-cli; fi
27+
@if [ -f 'hopp.bin' ]; then rm hopp.bin; fi
3628

3729
.PHONY: install
3830
install:
39-
@echo
40-
@echo Installing hopp-cli...
41-
@echo
31+
@printf '%s\n' 'Installing hopp-cli...'
4232
install -m755 hopp-cli $(BINDIR)
43-
@echo
44-
@echo ...Done\!
4533

4634
.PHONY: uninstall
4735
uninstall:
48-
@echo
49-
@echo Uninstalling hopp-cli...
50-
@echo
36+
@printf '%s\n' 'Uninstalling hopp-cli...'
5137
rm -f $(BINDIR)/hopp-cli
52-
@echo
53-
@echo ...Done\!
38+
5439
.PHONY: pack-releases
5540
pack-releases:
5641
$(foreach var,$(RELEASE_BUILDS),stuffbin -a stuff -in ${var} -out ${var} ${STATIC};)

cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"log"
66
"os"
77

8-
mets "github.com/athul/pwcli/methods"
98
"github.com/fatih/color"
9+
mets "github.com/hoppscotch/hopp-cli/methods"
1010
"github.com/urfave/cli"
1111
)
1212

go.mod

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
module github.com/athul/pwcli
1+
module github.com/hoppscotch/hopp-cli
22

3-
go 1.13
3+
go 1.16
44

55
require (
6-
github.com/fatih/color v1.9.0
6+
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
7+
github.com/fatih/color v1.13.0
78
github.com/knadh/stuffbin v1.1.0
8-
github.com/olekukonko/tablewriter v0.0.4
9-
github.com/pkg/browser v0.0.0-20201112035734-206646e67786
10-
github.com/stretchr/testify v1.4.0 // indirect
11-
github.com/tidwall/pretty v1.0.2
12-
github.com/urfave/cli v1.22.2
13-
github.com/yosssi/gohtml v0.0.0-20190915184251-7ff6f235ecaf
14-
go.uber.org/multierr v1.6.0
15-
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 // indirect
9+
github.com/mattn/go-colorable v0.1.12 // indirect
10+
github.com/mattn/go-runewidth v0.0.13 // indirect
11+
github.com/olekukonko/tablewriter v0.0.5
12+
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
13+
github.com/tidwall/pretty v1.2.0
14+
github.com/urfave/cli v1.22.5
15+
github.com/yosssi/gohtml v0.0.0-20201013000340-ee4748c638f4
16+
go.uber.org/atomic v1.9.0 // indirect
17+
go.uber.org/multierr v1.7.0
18+
golang.org/x/net v0.0.0-20211205041911-012df41ee64c // indirect
19+
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d // indirect
1620
)

go.sum

Lines changed: 50 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,66 @@
1-
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
21
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
3-
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
42
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
5-
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
3+
github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=
4+
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
65
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
76
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
87
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
9-
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
10-
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
8+
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
9+
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
1110
github.com/knadh/stuffbin v1.1.0 h1:f5S5BHzZALjuJEgTIOMC9NidEnBJM7Ze6Lu1GHR/lwU=
1211
github.com/knadh/stuffbin v1.1.0/go.mod h1:yVCFaWaKPubSNibBsTAJ939q2ABHudJQxRWZWV5yh+4=
13-
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
14-
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
15-
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
16-
github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=
17-
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
18-
github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54=
19-
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
20-
github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=
21-
github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
22-
github.com/pkg/browser v0.0.0-20201112035734-206646e67786 h1:4Gk0Dsp90g2YwfsxDOjvkEIgKGh+2R9FlvormRycveA=
23-
github.com/pkg/browser v0.0.0-20201112035734-206646e67786/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ=
12+
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
13+
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
14+
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
15+
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
16+
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
17+
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
18+
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
19+
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
20+
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
21+
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
22+
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
23+
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
24+
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
2425
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2526
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
26-
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
27+
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
28+
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
2729
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
28-
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
30+
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
31+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
2932
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
3033
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
3134
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
32-
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
33-
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
34-
github.com/tidwall/pretty v1.0.2 h1:Z7S3cePv9Jwm1KwS0513MRaoUe3S01WPbLNV40pwWZU=
35-
github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
36-
github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo=
37-
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
38-
github.com/yosssi/gohtml v0.0.0-20190915184251-7ff6f235ecaf h1:VA200mPTYh9FWY8zKX5ctXCtNk78HUez8ecTdsQGhoo=
39-
github.com/yosssi/gohtml v0.0.0-20190915184251-7ff6f235ecaf/go.mod h1:+ccdNT0xMY1dtc5XBxumbYfOUhmduiGudqaDgD2rVRE=
40-
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
35+
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
36+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
37+
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
38+
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
39+
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
40+
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
41+
github.com/yosssi/gohtml v0.0.0-20201013000340-ee4748c638f4 h1:0sw0nJM544SpsihWx1bkXdYLQDlzRflMgFJQ4Yih9ts=
42+
github.com/yosssi/gohtml v0.0.0-20201013000340-ee4748c638f4/go.mod h1:+ccdNT0xMY1dtc5XBxumbYfOUhmduiGudqaDgD2rVRE=
4143
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
42-
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
43-
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
44-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
45-
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI=
46-
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
47-
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
48-
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
49-
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
50-
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
51-
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
52-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
44+
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
45+
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
46+
go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec=
47+
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
48+
golang.org/x/net v0.0.0-20211205041911-012df41ee64c h1:7SfqwP5fxEtl/P02w5IhKc86ziJ+A25yFrkVgoy2FT8=
49+
golang.org/x/net v0.0.0-20211205041911-012df41ee64c/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
50+
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
51+
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
52+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
53+
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
54+
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
55+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
56+
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
57+
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d h1:FjkYO/PPp4Wi0EAUOVLxePm7qVW4r4ctbWpURyuOD0E=
58+
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
59+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
60+
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
61+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
5362
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
54-
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
5563
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
64+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
65+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
66+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

methods/basic.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func BasicRequestWithBody(c *cli.Context, method string) (string, error) {
3636

3737
req, err := http.NewRequest(method, url, bytes.NewBuffer(body))
3838
if err != nil {
39-
return "", fmt.Errorf("Error creating request: %s", err.Error())
39+
return "", fmt.Errorf("error creating request: %w", err)
4040
}
4141

4242
req.Header.Set("Content-Type", Contenttypes[c.String("ctype")])
@@ -59,7 +59,7 @@ func BasicRequestWithBody(c *cli.Context, method string) (string, error) {
5959
client := getHTTPClient()
6060
resp, err := client.Do(req)
6161
if err != nil {
62-
return "", fmt.Errorf("Error sending request: %s", err.Error())
62+
return "", fmt.Errorf("error sending request: %w", err)
6363
}
6464
defer resp.Body.Close()
6565

methods/fns.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package methods
33
import (
44
"encoding/base64"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"net/http"
88
"strings"
99

@@ -19,9 +19,9 @@ func formatresp(resp *http.Response) (string, error) {
1919
c := color.New(color.FgHiCyan)
2020
magenta := color.New(color.FgHiMagenta)
2121

22-
body, err := ioutil.ReadAll(resp.Body)
22+
body, err := io.ReadAll(resp.Body)
2323
if err != nil {
24-
return "", fmt.Errorf("Error reading response body: %s", err.Error())
24+
return "", fmt.Errorf("error reading response body: %w", err)
2525
}
2626

2727
for key, value := range resp.Header {
@@ -50,7 +50,7 @@ func basicAuth(username, password string) string {
5050
return base64.StdEncoding.EncodeToString([]byte(auth))
5151
}
5252

53-
//Contenttypes are used in Place for ctypes for sending requests
53+
// Contenttypes are used in Place for ctypes for sending requests
5454
var Contenttypes = map[string]string{
5555
"html": "text/html",
5656
"js": "application/json",

methods/get.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func Getbasic(c *cli.Context) (string, error) {
1717

1818
req, err := http.NewRequest("GET", url, nil)
1919
if err != nil {
20-
return "", fmt.Errorf("Error creating request: %s", err.Error())
20+
return "", fmt.Errorf("error creating request: %w", err)
2121
}
2222

2323
if c.String("token") != "" {
@@ -38,7 +38,7 @@ func Getbasic(c *cli.Context) (string, error) {
3838
client := getHTTPClient()
3939
resp, err := client.Do(req)
4040
if err != nil {
41-
return "", fmt.Errorf("Error sending request: %s", err.Error())
41+
return "", fmt.Errorf("error sending request: %w", err)
4242
}
4343
defer resp.Body.Close()
4444

methods/send.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8-
"io/ioutil"
98
"log"
109
"net/http"
1110
"os"
@@ -16,9 +15,9 @@ import (
1615
"go.uber.org/multierr"
1716
)
1817

19-
//ReadCollection reads the `hoppScotch-collection.json` File and returns a the Loaded Collection Struct
18+
// ReadCollection reads the `hoppScotch-collection.json` File and returns a the Loaded Collection Struct
2019
func ReadCollection(filename string) ([]Collection, error) {
21-
data, err := ioutil.ReadFile(filename)
20+
data, err := os.ReadFile(filename)
2221
if string(data) == "" {
2322
return nil, errors.New("PATH is needed")
2423
}
@@ -29,7 +28,7 @@ func ReadCollection(filename string) ([]Collection, error) {
2928
var jsonArr []Collection
3029
err = json.Unmarshal([]byte(data), &jsonArr) // Unmarshal JSON to Collection Type
3130
if err != nil {
32-
return nil, fmt.Errorf("Error parsing JSON: %s", err.Error())
31+
return nil, fmt.Errorf("error parsing JSON: %w", err)
3332
}
3433
return jsonArr, nil
3534
}
@@ -116,7 +115,7 @@ func (c *Collection) sendGET(req Requests) (string, string, string, error) {
116115
}
117116
}
118117
if err != nil {
119-
return "", "", "", fmt.Errorf("Error creating request: %s", err.Error())
118+
return "", "", "", fmt.Errorf("error creating request: %w", err)
120119
}
121120

122121
if req.Token != "" {
@@ -133,7 +132,7 @@ func (c *Collection) sendGET(req Requests) (string, string, string, error) {
133132
client := getHTTPClient()
134133
resp, err := client.Do(reqHTTP)
135134
if err != nil {
136-
return "", "", "", fmt.Errorf("Error sending request: %s", err.Error())
135+
return "", "", "", fmt.Errorf("error sending request: %w", err)
137136
}
138137
defer resp.Body.Close()
139138
// paramstr is suffixed with a `?` to append to the URL
@@ -177,7 +176,7 @@ func (c *Collection) sendPOST(req Requests, method string) (string, string, erro
177176

178177
finalBytes, err := json.RawMessage(jsonStr).MarshalJSON() // Marshal to JSON from strings
179178
if err != nil {
180-
return "", "", fmt.Errorf("Error Marhsaling JSON: %s", err.Error())
179+
return "", "", fmt.Errorf("error Marhsaling JSON: %w", err)
181180
}
182181
reqHTTP, err := http.NewRequest(method, url, bytes.NewBuffer(finalBytes))
183182
if len(req.Headers) > 0 {
@@ -186,7 +185,7 @@ func (c *Collection) sendPOST(req Requests, method string) (string, string, erro
186185
}
187186
}
188187
if err != nil {
189-
return "", "", fmt.Errorf("Error creating request: %s", err.Error())
188+
return "", "", fmt.Errorf("error creating request: %w", err)
190189
}
191190

192191
reqHTTP.Header.Set("Content-Type", req.Ctype) // Set Content type to said Ctype in Collection
@@ -203,7 +202,7 @@ func (c *Collection) sendPOST(req Requests, method string) (string, string, erro
203202
client := getHTTPClient()
204203
resp, err := client.Do(reqHTTP)
205204
if err != nil {
206-
return "", "", fmt.Errorf("Error sending request: %s", err.Error())
205+
return "", "", fmt.Errorf("error sending request: %w", err)
207206
}
208207

209208
defer resp.Body.Close()
@@ -245,7 +244,7 @@ func (c *Collection) getDatafromFolders() error {
245244
return nil
246245
}
247246

248-
//genTables generate the output in Tabular Form
247+
// genTables generate the output in Tabular Form
249248
func genTables(data [][]string) {
250249
table := tablewriter.NewWriter(os.Stdout)
251250
table.SetHeader([]string{"Name", "URL", "Method", "Status", "Code"})

0 commit comments

Comments
 (0)