Skip to content

Commit 6cf8e9c

Browse files
author
Gustvo Chain
committed
Make the linter happy!
1 parent 9ec7add commit 6cf8e9c

File tree

7 files changed

+99
-64
lines changed

7 files changed

+99
-64
lines changed

cmd/httplab/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ import (
1717
flag "github.com/spf13/pflag"
1818
)
1919

20+
// VERSION is the current version
2021
const VERSION = "v0.5.0-dev"
2122

23+
// NewHandler returns a new http.Handler
2224
func NewHandler(ui *ui.UI, g *gocui.Gui) http.Handler {
2325
fn := func(w http.ResponseWriter, req *http.Request) {
2426
if err := ui.AddRequest(g, req); err != nil {
@@ -54,6 +56,7 @@ func usage() {
5456
fmt.Fprintf(os.Stderr, "\nBindings:\n%s", ui.Bindings.Help())
5557
}
5658

59+
// Version prints the version and exits
5760
func Version() {
5861
fmt.Fprintf(os.Stdout, "%s\n", VERSION)
5962
os.Exit(0)

dump.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
var decolorizeRegex = regexp.MustCompile("\x1b\\[0;\\d+m")
1515

16+
// Decolorize remove the color escape sequences from a []byte encoded string
1617
func Decolorize(s []byte) []byte {
1718
return decolorizeRegex.ReplaceAll(s, nil)
1819
}
@@ -48,6 +49,7 @@ func writeBody(buf *bytes.Buffer, req *http.Request) error {
4849
return err
4950
}
5051

52+
// DumpRequest pretty prints an http.Request
5153
func DumpRequest(req *http.Request) ([]byte, error) {
5254
buf := bytes.NewBuffer(nil)
5355

dump_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import (
66
"net/http"
77
"testing"
88

9+
"sort"
10+
"strings"
11+
912
"github.com/stretchr/testify/assert"
1013
"github.com/stretchr/testify/require"
11-
"strings"
12-
"sort"
1314
)
1415

1516
func TestDumpRequestWithJSON(t *testing.T) {
@@ -50,14 +51,14 @@ func TestDumpRequestHeaders(t *testing.T) {
5051
sort.Strings(keys)
5152

5253
startLine := "GET / HTTP/1.1\n"
53-
response := startLine + strings.Join(keys, ": \n") + ": \n"
54+
response := startLine + strings.Join(keys, ": \n") + ": \n"
5455

5556
assert.Contains(t, response, string(Decolorize(buf)))
5657
})
5758
}
5859

5960
func TestDecolorization(t *testing.T) {
60-
for i, _ := range [107]struct{}{} {
61+
for i := range [107]struct{}{} {
6162
text := "Some Text"
6263
nocolor := Decolorize([]byte(withColor(i, text)))
6364
assert.Equal(t, text, string(nocolor))

response.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ func (m BodyMode) String() string {
2929
}
3030

3131
const (
32+
// BodyInput takes the body input from input box
3233
BodyInput BodyMode = iota + 1
34+
// BodyFile takes the body input from a file
3335
BodyFile
3436
)
3537

@@ -356,7 +358,7 @@ func (rl *ResponsesList) Del(key string) bool {
356358
// ExpandPath expands a given path by replacing '~' with $HOME of the current user.
357359
func ExpandPath(path string) string {
358360
if path[0] == '~' {
359-
path = "$HOME" + path[1:len(path)]
361+
path = "$HOME" + path[1:]
360362
}
361363
return os.ExpandEnv(path)
362364
}

ui/bindings.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/jroimartin/gocui"
99
)
1010

11+
// ActionFn is binded to a key combination
1112
type ActionFn func(*gocui.Gui, *gocui.View) error
1213

1314
type binding struct {
@@ -59,6 +60,7 @@ func (bs bindings) Help() string {
5960
return buf.String()
6061
}
6162

63+
// Bindings are the list of binded key combinations
6264
var Bindings = &bindings{
6365
{gocui.KeyTab, "Tab", "Next Input", nil, onNextView},
6466
{0xFF, "Shift+Tab", "Previous Input", nil, nil}, // only to display on help

ui/split.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ package ui
22

33
import "math"
44

5+
// Split simplifies the layout definition.
56
type Split struct {
67
size int
78
left int
89
points []int
910
index int
1011
}
1112

13+
// NewSplit returns a new Split
1214
func NewSplit(size int) *Split {
1315
return &Split{size: size, left: size, points: []int{0}}
1416
}
1517

18+
// Fixed defines a set of fixed or absolute points
1619
func (s *Split) Fixed(points ...int) *Split {
1720
for _, point := range points {
1821
s.points = append(s.points, point+(s.size-s.left))
@@ -22,6 +25,7 @@ func (s *Split) Fixed(points ...int) *Split {
2225
return s
2326
}
2427

28+
// Relative defines a set of relative points
2529
func (s *Split) Relative(points ...int) *Split {
2630
for _, point := range points {
2731
per := float64(point) / 100.0
@@ -31,16 +35,18 @@ func (s *Split) Relative(points ...int) *Split {
3135
return s
3236
}
3337

38+
// Next returns the next point in the set
3439
func (s *Split) Next() int {
3540
if s.index+1 == len(s.points) {
3641
return 0
3742
}
3843

39-
s.index += 1
44+
s.index = s.index + 1
4045
next := s.points[s.index]
4146
return next
4247
}
4348

49+
// Current returns the current point in the set
4450
func (s *Split) Current() int {
4551
return s.points[s.index]
4652
}

0 commit comments

Comments
 (0)