Skip to content

Commit

Permalink
golangci-lint run
Browse files Browse the repository at this point in the history
  • Loading branch information
ABHINAV-SUREKA committed Sep 11, 2024
1 parent 7059f17 commit 5a7e7d9
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 17 deletions.
10 changes: 5 additions & 5 deletions datadog/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,20 +222,20 @@ func newWriter(addr string) (ddWriter, error) {
return newUDPWriter(addr)
}

// noopWriter is a writer that does nothing
// noopWriter is a writer that does nothing.
type noopWriter struct{}

// Write writes nothing
func (w *noopWriter) Write(data []byte) (int, error) {
// Write writes nothing.
func (w *noopWriter) Write(_ []byte) (int, error) {
return 0, nil
}

// Close is a noop close
// Close is a noop close.
func (w *noopWriter) Close() error {
return nil
}

// CalcBufferSize returns the sizehint
// CalcBufferSize returns the sizehint.
func (w *noopWriter) CalcBufferSize(sizehint int) (int, error) {
return sizehint, nil
}
2 changes: 1 addition & 1 deletion datadog/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ main.http.rtt.seconds:0.001215296|h|#http_req_content_charset:,http_req_content_
count := int32(0)
expect := int32(strings.Count(data, "\n"))

addr, closer := startUDSTestServer(t, HandlerFunc(func(m Metric, _ net.Addr) {
addr, closer := startUDSTestServer(t, HandlerFunc(func(_ Metric, _ net.Addr) {
atomic.AddInt32(&count, 1)
}))
defer closer.Close()
Expand Down
4 changes: 2 additions & 2 deletions datadog/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func startUDPTestServer(t *testing.T, handler Handler) (addr string, closer io.C
return conn.LocalAddr().String(), conn
}

// startUDSTestServerWithSocketFile starts a UDS server with a given socket file
// startUDSTestServerWithSocketFile starts a UDS server with a given socket file.
func startUDSTestServerWithSocketFile(t *testing.T, socketPath string, handler Handler) (closer io.Closer) {
udsAddr, err := net.ResolveUnixAddr("unixgram", socketPath)
if err != nil {
Expand All @@ -130,7 +130,7 @@ func startUDSTestServerWithSocketFile(t *testing.T, socketPath string, handler H
}
}

// startUDSTestServer starts a UDS server with a random socket file internally generated
// startUDSTestServer starts a UDS server with a random socket file internally generated.
func startUDSTestServer(t *testing.T, handler Handler) (socketPath string, closer io.Closer) {
// generate a random dir
dir, err := os.MkdirTemp("", "socket")
Expand Down
3 changes: 1 addition & 2 deletions datadog/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ func newUDPWriter(addr string) (*udpWriter, error) {
}
fmt.Printf("udp conn: %#v\n", conn)
return &udpWriter{conn: conn}, nil

}

// Write data to the UDP connection
// Write data to the UDP connection.
func (w *udpWriter) Write(data []byte) (int, error) {
return w.conn.Write(data)
}
Expand Down
2 changes: 1 addition & 1 deletion datadog/uds.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func newUDSWriter(addr string) (*udsWriter, error) {
}

// Write data to the UDS connection with write timeout and minimal error handling:
// create the connection if nil, and destroy it if the statsd server has disconnected
// create the connection if nil, and destroy it if the statsd server has disconnected.
func (w *udsWriter) Write(data []byte) (int, error) {
conn, err := w.ensureConnection()
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions datadog/uds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ func TestUDSReconnectsWhenConnRefused(t *testing.T) {
t.Errorf("got no error but expected one as the connection should be refused as we closed the server")
}
// restart UDS server with same socket file
closerServer2 := startUDSTestServerWithSocketFile(t, socketPath, HandlerFunc(func(m Metric, _ net.Addr) {}))
closerServer2 := startUDSTestServerWithSocketFile(t, socketPath, HandlerFunc(func(_ Metric, _ net.Addr) {}))
defer closerServer2.Close()

_, err = client.Write([]byte(measure))
if err != nil {
t.Errorf("unable to write data but should be able to as the client should reconnect %v", err)
}

}
2 changes: 1 addition & 1 deletion procstats/delaystats_darwin.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package procstats

func collectDelayInfo(pid int) (info DelayInfo) {
func collectDelayInfo(_ int) (info DelayInfo) {
// TODO
return
}
2 changes: 1 addition & 1 deletion procstats/linux/memory_darwin.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package linux

func readMemoryLimit(pid int) (limit uint64, err error) {
func readMemoryLimit(_ int) (limit uint64, err error) {
limit = unlimitedMemoryLimit
return
}
4 changes: 2 additions & 2 deletions procstats/proc_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ func collectProcInfo(pid int) (info ProcInfo, err error) {
func memoryAvailable() uint64 {
mib := [2]C.int{C.CTL_HW, C.HW_MEMSIZE}
mem := C.int64_t(0)
len := C.size_t(8) // sizeof(int64_t)
length := C.size_t(8) // sizeof(int64_t)

_, err := C.sysctl(&mib[0], 2, unsafe.Pointer(&mem), &len, nil, 0)
_, err := C.sysctl(&mib[0], 2, unsafe.Pointer(&mem), &length, nil, 0)
check(err)

return uint64(mem)
Expand Down

0 comments on commit 5a7e7d9

Please sign in to comment.