Skip to content

Commit 89bbfaa

Browse files
committed
fixing misc lint errors
1 parent 309e6bc commit 89bbfaa

File tree

6 files changed

+13
-16
lines changed

6 files changed

+13
-16
lines changed

.golangci.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ linters-settings:
4141
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
4242
# lll:
4343
# line-length: 140
44-
maligned:
45-
suggest-new: true
4644
misspell:
4745
locale: US
4846
nolintlint:
@@ -73,14 +71,12 @@ linters:
7371
- gosimple
7472
- govet
7573
- ineffassign
76-
- interfacer
77-
- maligned
7874
- misspell
7975
- nakedret
8076
- noctx
8177
- nolintlint
8278
- rowserrcheck
83-
- scopelint
79+
- exportloopref
8480
- staticcheck
8581
- structcheck
8682
- stylecheck

cmd/simplehttpserver/simplehttpserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ func main() {
1616
if err := r.Run(); err != nil {
1717
gologger.Info().Msgf("%s\n", err)
1818
}
19-
defer r.Close()
19+
defer r.Close() //nolint
2020
}

internal/runner/options.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ func (options *Options) configureOutput() {
9595
}
9696

9797
// FolderAbsPath of the fileserver folder
98-
func (o *Options) FolderAbsPath() string {
99-
abspath, err := filepath.Abs(o.Folder)
98+
func (options *Options) FolderAbsPath() string {
99+
abspath, err := filepath.Abs(options.Folder)
100100
if err != nil {
101-
return o.Folder
101+
return options.Folder
102102
}
103103
return abspath
104104
}

internal/runner/runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func New(options *Options) (*Runner, error) {
2828
}
2929

3030
if r.options.EnableTCP {
31-
serverTCP, err := tcpserver.New(tcpserver.Options{
31+
serverTCP, err := tcpserver.New(&tcpserver.Options{
3232
Listen: r.options.ListenAddress,
3333
TLS: r.options.TCPWithTLS,
3434
Domain: "local.host",

pkg/binder/binder.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@ func GetRandomListenAddress(currentAddress string) (string, error) {
3333
}
3434

3535
return net.JoinHostPort(addrOrig, fmt.Sprintf("%d", newPort)), nil
36-
3736
}

pkg/tcpserver/tcpserver.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"gopkg.in/yaml.v2"
1212
)
1313

14+
const readTimeout = 5
15+
1416
// Options of the tcp server
1517
type Options struct {
1618
Listen string
@@ -24,12 +26,12 @@ type Options struct {
2426

2527
// TCPServer instance
2628
type TCPServer struct {
27-
options Options
29+
options *Options
2830
listener net.Listener
2931
}
3032

3133
// New tcp server instance with specified options
32-
func New(options Options) (*TCPServer, error) {
34+
func New(options *Options) (*TCPServer, error) {
3335
return &TCPServer{options: options}, nil
3436
}
3537

@@ -50,11 +52,11 @@ func (t *TCPServer) ListenAndServe() error {
5052
}
5153

5254
func (t *TCPServer) handleConnection(conn net.Conn) error {
53-
defer conn.Close()
55+
defer conn.Close() //nolint
5456

5557
buf := make([]byte, 4096)
5658
for {
57-
if err := conn.SetReadDeadline(time.Now().Add(time.Duration(5 * time.Second))); err != nil {
59+
if err := conn.SetReadDeadline(time.Now().Add(readTimeout * time.Second)); err != nil {
5860
gologger.Info().Msgf("%s\n", err)
5961
}
6062
_, err := conn.Read(buf)
@@ -77,7 +79,7 @@ func (t *TCPServer) handleConnection(conn net.Conn) error {
7779
}
7880
}
7981

80-
// ListenAndServe requests over tls
82+
// ListenAndServeTLS requests over tls
8183
func (t *TCPServer) ListenAndServeTLS() error {
8284
var tlsConfig *tls.Config
8385
if t.options.Certificate != "" && t.options.Key != "" {

0 commit comments

Comments
 (0)