diff --git a/pkg/archive/archive.go b/pkg/archive/archive.go index ebe55eddc2..cdaf7ea2a3 100644 --- a/pkg/archive/archive.go +++ b/pkg/archive/archive.go @@ -385,7 +385,6 @@ func ReplaceFileTarWrapper(inputTarStream io.ReadCloser, mods map[string]TarModi } pipeWriter.Close() - }() return pipeReader } @@ -772,7 +771,6 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L } return err } - } if len(errors) > 0 { diff --git a/pkg/archive/archive_linux_test.go b/pkg/archive/archive_linux_test.go index bfc84ad91b..efff0dddcf 100644 --- a/pkg/archive/archive_linux_test.go +++ b/pkg/archive/archive_linux_test.go @@ -61,7 +61,6 @@ func checkOpaqueness(t *testing.T, path string, opaque string) { if string(xattrOpaque) != opaque { t.Fatalf("Unexpected opaque value: %q, expected %q", string(xattrOpaque), opaque) } - } func checkOverlayWhiteout(t *testing.T, path string) { diff --git a/pkg/archive/changes.go b/pkg/archive/changes.go index 9ad7d7efb8..7f7242be50 100644 --- a/pkg/archive/changes.go +++ b/pkg/archive/changes.go @@ -246,7 +246,6 @@ func (info *FileInfo) path() string { } func (info *FileInfo) addChanges(oldInfo *FileInfo, changes *[]Change) { - sizeAtEntry := len(*changes) if oldInfo == nil { @@ -319,7 +318,6 @@ func (info *FileInfo) addChanges(oldInfo *FileInfo, changes *[]Change) { copy((*changes)[sizeAtEntry+1:], (*changes)[sizeAtEntry:]) (*changes)[sizeAtEntry] = change } - } // Changes add changes to file information. diff --git a/pkg/archive/changes_posix_test.go b/pkg/archive/changes_posix_test.go index cdf854c438..84864a6bcf 100644 --- a/pkg/archive/changes_posix_test.go +++ b/pkg/archive/changes_posix_test.go @@ -102,7 +102,6 @@ func TestHardLinkOrder(t *testing.T) { t.Errorf("headers - %q expected linkname %q; but got %q", hdrs[i].Name, hdrs[i].Linkname, hdrsRev[i].Linkname) } } - } type tarHeaders []tar.Header diff --git a/pkg/archive/copy.go b/pkg/archive/copy.go index 90d23cdc08..0ea1596278 100644 --- a/pkg/archive/copy.go +++ b/pkg/archive/copy.go @@ -303,7 +303,6 @@ func PrepareArchiveCopy(srcContent io.Reader, srcInfo, dstInfo CopyInfo) (dstDir } return dstDir, RebaseArchiveEntries(srcContent, srcBase, dstBase), nil } - } // RebaseArchiveEntries rewrites the given srcContent archive replacing diff --git a/pkg/archive/copy_unix_test.go b/pkg/archive/copy_unix_test.go index 2f421fe78e..f8fca00ce6 100644 --- a/pkg/archive/copy_unix_test.go +++ b/pkg/archive/copy_unix_test.go @@ -372,7 +372,6 @@ func TestCopyCaseB(t *testing.T) { if err != ErrDirNotExists { t.Fatalf("expected ErrDirNotExists error, but got %T: %s", err, err) } - } // C. SRC specifies a file and DST exists as a file. diff --git a/pkg/archive/diff_test.go b/pkg/archive/diff_test.go index aac7b7c340..a8ba68e0a7 100644 --- a/pkg/archive/diff_test.go +++ b/pkg/archive/diff_test.go @@ -308,7 +308,6 @@ func TestApplyLayerWhiteouts(t *testing.T) { t.Fatalf("invalid files for layer %d: expected %q, got %q", i, tc.expected, paths) } } - } func makeTestLayer(paths []string) (rc io.ReadCloser, err error) { diff --git a/pkg/authorization/api_test.go b/pkg/authorization/api_test.go index 8e05c917d1..8ae9d98fb5 100644 --- a/pkg/authorization/api_test.go +++ b/pkg/authorization/api_test.go @@ -68,9 +68,6 @@ func TestPeerCertificateMarshalJSON(t *testing.T) { assert.Assert(t, is.Nil(err)) assert.Equal(t, "Earth", pcObj.Subject.Country[0]) assert.Equal(t, true, pcObj.IsCA) - }) - } - } diff --git a/pkg/authorization/middleware_test.go b/pkg/authorization/middleware_test.go index c7597d35c6..4563379fba 100644 --- a/pkg/authorization/middleware_test.go +++ b/pkg/authorization/middleware_test.go @@ -43,7 +43,6 @@ func TestNewResponseModifier(t *testing.T) { if recorder.Header().Get("H1") != "V1" { t.Fatalf("Header value must exists %s", recorder.Header().Get("H1")) } - } func setAuthzPlugins(m *Middleware, plugins []Plugin) { diff --git a/pkg/authorization/middleware_unix_test.go b/pkg/authorization/middleware_unix_test.go index 2587f9dc2a..b29e7d272d 100644 --- a/pkg/authorization/middleware_unix_test.go +++ b/pkg/authorization/middleware_unix_test.go @@ -50,7 +50,6 @@ func TestMiddlewareWrapHandler(t *testing.T) { if err := mdHandler(ctx, resp, req, map[string]string{}); err == nil { assert.Assert(t, is.ErrorContains(err, "")) } - }) t.Run("Positive Test Case :", func(t *testing.T) { @@ -61,7 +60,5 @@ func TestMiddlewareWrapHandler(t *testing.T) { if err := mdHandler(ctx, resp, req, map[string]string{}); err != nil { assert.NilError(t, err) } - }) - } diff --git a/pkg/authorization/response.go b/pkg/authorization/response.go index 82beb5be80..c9e9a2c85f 100644 --- a/pkg/authorization/response.go +++ b/pkg/authorization/response.go @@ -67,9 +67,8 @@ func (rm *responseModifier) Hijacked() bool { return rm.hijacked } -// WriterHeader stores the http status code +// WriteHeader stores the http status code func (rm *responseModifier) WriteHeader(s int) { - // Use original request if hijacked if rm.hijacked { rm.rw.WriteHeader(s) @@ -81,7 +80,6 @@ func (rm *responseModifier) WriteHeader(s int) { // Header returns the internal http header func (rm *responseModifier) Header() http.Header { - // Use original header if hijacked if rm.hijacked { return rm.rw.Header() @@ -143,7 +141,6 @@ func (rm *responseModifier) RawHeaders() ([]byte, error) { // Hijack returns the internal connection of the wrapped http.ResponseWriter func (rm *responseModifier) Hijack() (net.Conn, *bufio.ReadWriter, error) { - rm.hijacked = true rm.FlushAll() diff --git a/pkg/devicemapper/devmapper.go b/pkg/devicemapper/devmapper.go index 38cba829d0..a003e59c52 100644 --- a/pkg/devicemapper/devmapper.go +++ b/pkg/devicemapper/devmapper.go @@ -237,12 +237,8 @@ func (t *Task) getDriverVersion() (string, error) { return res, nil } -func (t *Task) getNextTarget(next unsafe.Pointer) (nextPtr unsafe.Pointer, start uint64, - length uint64, targetType string, params string) { - - return DmGetNextTarget(t.unmanaged, next, &start, &length, - &targetType, ¶ms), - start, length, targetType, params +func (t *Task) getNextTarget(next unsafe.Pointer) (nextPtr unsafe.Pointer, start uint64, length uint64, targetType string, params string) { + return DmGetNextTarget(t.unmanaged, next, &start, &length, &targetType, ¶ms), start, length, targetType, params } // UdevWait waits for any processes that are waiting for udev to complete the specified cookie. @@ -396,7 +392,6 @@ func CancelDeferredRemove(deviceName string) error { return ErrEnxio } return fmt.Errorf("devicemapper: Error running CancelDeferredRemove %s", err) - } return nil } @@ -680,7 +675,6 @@ func CreateDevice(poolName string, deviceID int) error { } return fmt.Errorf("devicemapper: Error running CreateDevice %s", err) - } return nil } diff --git a/pkg/devicemapper/devmapper_wrapper.go b/pkg/devicemapper/devmapper_wrapper.go index 103d54e7d5..0d34c1ca9a 100644 --- a/pkg/devicemapper/devmapper_wrapper.go +++ b/pkg/devicemapper/devmapper_wrapper.go @@ -132,9 +132,7 @@ func dmTaskSetAddNodeFct(task *cdmTask, addNode AddNodeType) int { return int(C.dm_task_set_add_node((*C.struct_dm_task)(task), C.dm_add_node_t(addNode))) } -func dmTaskAddTargetFct(task *cdmTask, - start, size uint64, ttype, params string) int { - +func dmTaskAddTargetFct(task *cdmTask, start, size uint64, ttype, params string) int { Cttype := C.CString(ttype) defer free(Cttype) diff --git a/pkg/directory/directory.go b/pkg/directory/directory.go index 71e8cfee77..f0c45303cd 100644 --- a/pkg/directory/directory.go +++ b/pkg/directory/directory.go @@ -7,7 +7,6 @@ import ( // MoveToSubdir moves all contents of a directory to a subdirectory underneath the original path func MoveToSubdir(oldpath, subdir string) error { - infos, err := os.ReadDir(oldpath) if err != nil { return err diff --git a/pkg/fileutils/fileutils_test.go b/pkg/fileutils/fileutils_test.go index 3eb7b520e9..ce6ddd18ea 100644 --- a/pkg/fileutils/fileutils_test.go +++ b/pkg/fileutils/fileutils_test.go @@ -27,7 +27,6 @@ func TestCopyFileWithInvalidSrc(t *testing.T) { if bytes != 0 { t.Fatal("Should have written 0 bytes") } - } // CopyFile with invalid dest @@ -49,7 +48,6 @@ func TestCopyFileWithInvalidDest(t *testing.T) { if bytes != 0 { t.Fatal("Should have written 0 bytes") } - } // CopyFile with same src and dest @@ -492,7 +490,6 @@ func TestMatches(t *testing.T) { check(pm, test.text, test.pass, desc) } }) - } func TestCleanPatterns(t *testing.T) { diff --git a/pkg/idtools/idtools_unix.go b/pkg/idtools/idtools_unix.go index 98330d2b23..2758726cc2 100644 --- a/pkg/idtools/idtools_unix.go +++ b/pkg/idtools/idtools_unix.go @@ -213,7 +213,6 @@ func callGetent(database, key string) (io.Reader, error) { default: return nil, err } - } return bytes.NewReader(out), nil } diff --git a/pkg/idtools/usergroupadd_linux.go b/pkg/idtools/usergroupadd_linux.go index bf7ae0564b..3ad9255df2 100644 --- a/pkg/idtools/usergroupadd_linux.go +++ b/pkg/idtools/usergroupadd_linux.go @@ -88,7 +88,6 @@ func addUser(name string) error { } func createSubordinateRanges(name string) error { - // first, we should verify that ranges weren't automatically created // by the distro tooling ranges, err := parseSubuid(name) diff --git a/pkg/ioutils/bytespipe_test.go b/pkg/ioutils/bytespipe_test.go index 5e36187482..74644e4a95 100644 --- a/pkg/ioutils/bytespipe_test.go +++ b/pkg/ioutils/bytespipe_test.go @@ -119,7 +119,6 @@ func TestBytesPipeWriteRandomChunks(t *testing.T) { if expected != actual { t.Fatalf("BytesPipe returned invalid data. Expected checksum %v, got %v", expected, actual) } - } } diff --git a/pkg/ioutils/fswriters_test.go b/pkg/ioutils/fswriters_test.go index d635561388..3cc7bbfc9d 100644 --- a/pkg/ioutils/fswriters_test.go +++ b/pkg/ioutils/fswriters_test.go @@ -95,7 +95,6 @@ func TestAtomicWriteSetCommit(t *testing.T) { if expected := testMode; st.Mode() != expected { t.Fatalf("Mode mismatched, expected %o, got %o", expected, st.Mode()) } - } func TestAtomicWriteSetCancel(t *testing.T) { diff --git a/pkg/ioutils/writers_test.go b/pkg/ioutils/writers_test.go index 94d446f9a9..00c966e25d 100644 --- a/pkg/ioutils/writers_test.go +++ b/pkg/ioutils/writers_test.go @@ -27,7 +27,6 @@ func TestNopWriteCloser(t *testing.T) { if err := wrapper.Close(); err != nil { t.Fatal("NopWriteCloser always return nil on Close.") } - } func TestNopWriter(t *testing.T) { diff --git a/pkg/loopback/attach_loopback.go b/pkg/loopback/attach_loopback.go index 68135d87a8..c9e1d0f72c 100644 --- a/pkg/loopback/attach_loopback.go +++ b/pkg/loopback/attach_loopback.go @@ -94,7 +94,6 @@ func openNextAvailableLoopback(index int, sparseFile *os.File) (loopFile *os.Fil // AttachLoopDevice attaches the given sparse file to the next // available loopback device. It returns an opened *os.File. func AttachLoopDevice(sparseName string) (loop *os.File, err error) { - // Try to retrieve the next available loopback device via syscall. // If it fails, we discard error and start looping for a // loopback from index 0. diff --git a/pkg/namesgenerator/names-generator_test.go b/pkg/namesgenerator/names-generator_test.go index 8702697745..8d394fbb30 100644 --- a/pkg/namesgenerator/names-generator_test.go +++ b/pkg/namesgenerator/names-generator_test.go @@ -23,7 +23,6 @@ func TestNameRetries(t *testing.T) { if !strings.ContainsAny(name, "0123456789") { t.Fatalf("Generated name doesn't contain a number") } - } func BenchmarkGetRandomName(b *testing.B) { diff --git a/pkg/plugins/plugins.go b/pkg/plugins/plugins.go index c352d10663..6f21665e90 100644 --- a/pkg/plugins/plugins.go +++ b/pkg/plugins/plugins.go @@ -151,7 +151,6 @@ func (p *Plugin) runHandlers() { p.handlersRun = true } handlers.RUnlock() - } // activated returns if the plugin has already been activated. diff --git a/pkg/sysinfo/sysinfo_linux_test.go b/pkg/sysinfo/sysinfo_linux_test.go index f84b416297..252450fc74 100644 --- a/pkg/sysinfo/sysinfo_linux_test.go +++ b/pkg/sysinfo/sysinfo_linux_test.go @@ -33,7 +33,6 @@ func TestReadProcBool(t *testing.T) { if readProcBool(path.Join(tmpDir, "no-exist")) { t.Fatal("should be false for non-existent entry") } - } func TestCgroupEnabled(t *testing.T) { diff --git a/pkg/system/meminfo_linux.go b/pkg/system/meminfo_linux.go index d407739858..02a7377c1f 100644 --- a/pkg/system/meminfo_linux.go +++ b/pkg/system/meminfo_linux.go @@ -55,7 +55,6 @@ func parseMemInfo(reader io.Reader) (*MemInfo, error) { case "SwapFree:": meminfo.SwapFree = bytes } - } if memAvailable != -1 { meminfo.MemFree = memAvailable diff --git a/pkg/system/path.go b/pkg/system/path.go index 7561361d54..5c79f60985 100644 --- a/pkg/system/path.go +++ b/pkg/system/path.go @@ -13,7 +13,6 @@ func DefaultPathEnv(os string) string { return "" } return defaultUnixPathEnv - } // CheckSystemDriveAndRemoveDriveLetter verifies that a path, if it includes a drive letter, diff --git a/pkg/tailfile/tailfile.go b/pkg/tailfile/tailfile.go index 90f5a7f360..afc84f00bb 100644 --- a/pkg/tailfile/tailfile.go +++ b/pkg/tailfile/tailfile.go @@ -216,6 +216,5 @@ func (s *scanner) Scan(ctx context.Context) bool { // It's much simpler and cleaner to just re-read `len(delimiter)-1` bytes again. s.pos += int64(len(s.delim)) - 1 } - } } diff --git a/pkg/tarsum/fileinfosums_test.go b/pkg/tarsum/fileinfosums_test.go index e6ebd9cc86..7d71474e53 100644 --- a/pkg/tarsum/fileinfosums_test.go +++ b/pkg/tarsum/fileinfosums_test.go @@ -58,5 +58,4 @@ func TestSortFileInfoSums(t *testing.T) { if fis.GetFile("noPresent") != nil { t.Error("Should have return nil if name not found.") } - } diff --git a/pkg/tarsum/tarsum_test.go b/pkg/tarsum/tarsum_test.go index 1945f4a5cf..bf5a31288a 100644 --- a/pkg/tarsum/tarsum_test.go +++ b/pkg/tarsum/tarsum_test.go @@ -196,7 +196,6 @@ func TestNewTarSumForLabelInvalid(t *testing.T) { } func TestNewTarSumForLabel(t *testing.T) { - layer := testLayers[0] reader, err := os.Open(layer.filename) @@ -292,7 +291,6 @@ func TestTarSumsReadSize(t *testing.T) { layer := testLayers[0] for i := 0; i < 5; i++ { - reader, err := os.Open(layer.filename) if err != nil { t.Fatal(err) @@ -515,7 +513,6 @@ func TestIteration(t *testing.T) { t.Errorf("expected sum: %q, got: %q", htest.expectedSum, s) } } - } func renderSumForHeader(v Version, h *tar.Header, data []byte) (string, error) {