From 910d0cc3f527795b3ba9ddb7c6244665b516b0ff Mon Sep 17 00:00:00 2001 From: celogeek <65178+celogeek@users.noreply.github.com> Date: Sun, 3 Mar 2024 12:31:26 +0100 Subject: [PATCH] lint ignore --- internal/piwigo/piwigotools/file_to_upload.go | 3 +++ internal/piwigo/piwigotools/image_details.go | 2 ++ internal/piwigo/piwigotools/tags.go | 2 ++ internal/piwigo/videojs.go | 1 + internal/tree/tree.go | 20 +++++++------------ 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/internal/piwigo/piwigotools/file_to_upload.go b/internal/piwigo/piwigotools/file_to_upload.go index 255af25..4370aa9 100644 --- a/internal/piwigo/piwigotools/file_to_upload.go +++ b/internal/piwigo/piwigotools/file_to_upload.go @@ -75,6 +75,7 @@ func (f *FileToUpload) MD5() *string { if err != nil { return nil } + //goland:noinspection GoUnhandledErrorResult defer file.Close() hash := md5.New() if _, err = io.Copy(hash, file); err != nil { @@ -95,6 +96,7 @@ func (f *FileToUpload) CreatedAt() *TimeResult { if err != nil { return nil } + //goland:noinspection GoUnhandledErrorResult defer et.Close() var createdAt *time.Time @@ -163,6 +165,7 @@ func (f *FileToUpload) Base64BuildChunk() (chan *FileToUploadChunk, error) { out := make(chan *FileToUploadChunk, 8) go func() { b := make([]byte, ChunkBuffSize) + //goland:noinspection GoUnhandledErrorResult defer fh.Close() defer close(out) ok := false diff --git a/internal/piwigo/piwigotools/image_details.go b/internal/piwigo/piwigotools/image_details.go index 3a7d6cd..3999b86 100644 --- a/internal/piwigo/piwigotools/image_details.go +++ b/internal/piwigo/piwigotools/image_details.go @@ -43,6 +43,7 @@ func (img *ImageDetails) Preview(height int) (string, error) { if resp.StatusCode != 200 { return "", fmt.Errorf("[error %d] failed to get image", resp.StatusCode) } + //goland:noinspection GoUnhandledErrorResult defer resp.Body.Close() buf := bytes.NewBuffer([]byte{}) @@ -57,6 +58,7 @@ func (img *ImageDetails) Preview(height int) (string, error) { buf.WriteString(":") encoder := base64.NewEncoder(base64.StdEncoding, buf) + //goland:noinspection GoUnhandledErrorResult defer encoder.Close() if _, err := io.Copy(encoder, resp.Body); err != nil { return "", err diff --git a/internal/piwigo/piwigotools/tags.go b/internal/piwigo/piwigotools/tags.go index 8b99422..08adab0 100644 --- a/internal/piwigo/piwigotools/tags.go +++ b/internal/piwigo/piwigotools/tags.go @@ -63,8 +63,10 @@ func (t Tags) Selector(exclude *regexp.Regexp, keepFilter bool, keepPreviousAnsw tags[tag.Name] = tag } + //goland:noinspection GoPreferNilSlice previousAnswer := []string{} return func() Tags { + //goland:noinspection GoPreferNilSlice answer := []string{} _ = survey.AskOne(&survey.MultiSelect{ diff --git a/internal/piwigo/videojs.go b/internal/piwigo/videojs.go index 070d8c5..c7ccf6d 100644 --- a/internal/piwigo/videojs.go +++ b/internal/piwigo/videojs.go @@ -31,6 +31,7 @@ func (p *Piwigo) VideoJSSync(imageId int) error { if err != nil { return err } + //goland:noinspection GoUnhandledErrorResult defer r.Body.Close() return nil } diff --git a/internal/tree/tree.go b/internal/tree/tree.go index 16692ef..2320f61 100644 --- a/internal/tree/tree.go +++ b/internal/tree/tree.go @@ -1,5 +1,5 @@ /* -Tree builder and viewer +Package tree builder and viewer This allows you to create a tree of files and display them as a tree or flat view. @@ -32,9 +32,7 @@ type Tree interface { TreeView() chan string } -/* -Create a new tree -*/ +// New create a new tree func New() Tree { return &node{ Name: ".", @@ -73,7 +71,7 @@ func (t *node) Add(name string) Tree { } /* -Add a path to your tree, separated with / +AddPath add a path to your tree, separated with / t.AddPath("a/b/c/d") */ @@ -85,9 +83,7 @@ func (t *node) AddPath(path string) Tree { return n } -/* -Return a sorted list of children -*/ +// Children return a sorted list of children func (t *node) Children() []*node { children := make([]*node, len(t.Nodes)) i := 0 @@ -101,15 +97,13 @@ func (t *node) Children() []*node { return children } -/* -Check if your node has a children -*/ +// HasChildren Check if your node has a children func (t *node) HasChildren() bool { return t.Nodes != nil } /* -Return a flat view of your tree +FlatView return a flat view of your tree for v := range t.FlatView() { fmt.Println(v) @@ -138,7 +132,7 @@ func (t *node) FlatView() (out chan string) { } /* -Return a tree view of your tree +TreeView return a tree view of your tree for v := range t.TreeView() { fmt.Println(v)