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

Commit

Permalink
Dependencies, go version update, and Makefile fixes (#44)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
gbmor authored Dec 15, 2021
1 parent 8fc5452 commit e5f4f91
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*.so
*.dylib
hopp-cli
hoop.bin
hopp.bin
dist/

# Test binary, built with `go test -c`
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sudo: false
language: go

go:
- "1.13"
- "1.16.x"
before_script:
- go get -v
- go build
Expand Down
53 changes: 19 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,56 +1,41 @@
BIN:=hopp.bin
BINSTUFFED:=hopp-cli
PREFIX?=/usr/local
BINDIR?=$(PREFIX)/bin
VERSION?=$(shell git tag | grep ^v | sort -V | tail -n 1)
STATIC := ./templates/index.html ./templates/template.md:/template.md

all: deps build

.PHONY: deps
deps:
go get -u github.com/knadh/stuffbin/...
@printf '%s\n' 'Checking binary dependencies...'
@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

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

.PHONY: clean
clean:
@echo
@echo Cleaning...
@echo
go clean
@echo
@echo ...Done\!

.PHONY: update
update:
@echo
@echo Updating from upstream repository...
@echo
git pull --rebase origin master
@echo
@echo ...Done\!
@printf '%s\n' 'Cleaning...'
@go clean
@if [ -f 'hopp-cli' ]; then rm hopp-cli; fi
@if [ -f 'hopp.bin' ]; then rm hopp.bin; fi

.PHONY: install
install:
@echo
@echo Installing hopp-cli...
@echo
@printf '%s\n' 'Installing hopp-cli...'
install -m755 hopp-cli $(BINDIR)
@echo
@echo ...Done\!

.PHONY: uninstall
uninstall:
@echo
@echo Uninstalling hopp-cli...
@echo
@printf '%s\n' 'Uninstalling hopp-cli...'
rm -f $(BINDIR)/hopp-cli
@echo
@echo ...Done\!

.PHONY: pack-releases
pack-releases:
$(foreach var,$(RELEASE_BUILDS),stuffbin -a stuff -in ${var} -out ${var} ${STATIC};)
2 changes: 1 addition & 1 deletion cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"log"
"os"

mets "github.com/athul/pwcli/methods"
"github.com/fatih/color"
mets "github.com/hoppscotch/hopp-cli/methods"
"github.com/urfave/cli"
)

Expand Down
26 changes: 15 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
module github.com/athul/pwcli
module github.com/hoppscotch/hopp-cli

go 1.13
go 1.16

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

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

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

Expand Down
8 changes: 4 additions & 4 deletions methods/fns.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package methods
import (
"encoding/base64"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"

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

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

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

//Contenttypes are used in Place for ctypes for sending requests
// Contenttypes are used in Place for ctypes for sending requests
var Contenttypes = map[string]string{
"html": "text/html",
"js": "application/json",
Expand Down
4 changes: 2 additions & 2 deletions methods/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func Getbasic(c *cli.Context) (string, error) {

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

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

Expand Down
19 changes: 9 additions & 10 deletions methods/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
Expand All @@ -16,9 +15,9 @@ import (
"go.uber.org/multierr"
)

//ReadCollection reads the `hoppScotch-collection.json` File and returns a the Loaded Collection Struct
// ReadCollection reads the `hoppScotch-collection.json` File and returns a the Loaded Collection Struct
func ReadCollection(filename string) ([]Collection, error) {
data, err := ioutil.ReadFile(filename)
data, err := os.ReadFile(filename)
if string(data) == "" {
return nil, errors.New("PATH is needed")
}
Expand All @@ -29,7 +28,7 @@ func ReadCollection(filename string) ([]Collection, error) {
var jsonArr []Collection
err = json.Unmarshal([]byte(data), &jsonArr) // Unmarshal JSON to Collection Type
if err != nil {
return nil, fmt.Errorf("Error parsing JSON: %s", err.Error())
return nil, fmt.Errorf("error parsing JSON: %w", err)
}
return jsonArr, nil
}
Expand Down Expand Up @@ -116,7 +115,7 @@ func (c *Collection) sendGET(req Requests) (string, string, string, error) {
}
}
if err != nil {
return "", "", "", fmt.Errorf("Error creating request: %s", err.Error())
return "", "", "", fmt.Errorf("error creating request: %w", err)
}

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

finalBytes, err := json.RawMessage(jsonStr).MarshalJSON() // Marshal to JSON from strings
if err != nil {
return "", "", fmt.Errorf("Error Marhsaling JSON: %s", err.Error())
return "", "", fmt.Errorf("error Marhsaling JSON: %w", err)
}
reqHTTP, err := http.NewRequest(method, url, bytes.NewBuffer(finalBytes))
if len(req.Headers) > 0 {
Expand All @@ -186,7 +185,7 @@ func (c *Collection) sendPOST(req Requests, method string) (string, string, erro
}
}
if err != nil {
return "", "", fmt.Errorf("Error creating request: %s", err.Error())
return "", "", fmt.Errorf("error creating request: %w", err)
}

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

defer resp.Body.Close()
Expand Down Expand Up @@ -245,7 +244,7 @@ func (c *Collection) getDatafromFolders() error {
return nil
}

//genTables generate the output in Tabular Form
// genTables generate the output in Tabular Form
func genTables(data [][]string) {
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Name", "URL", "Method", "Status", "Code"})
Expand Down
Loading

0 comments on commit e5f4f91

Please # to comment.