From 47e078605e5b01b12c04fd7489543fce56574fd1 Mon Sep 17 00:00:00 2001 From: yukionishi1129 Date: Sun, 31 Mar 2024 22:52:56 +0900 Subject: [PATCH] fix lint --- batch-service/.golangci.yml | 13 +++++++++++++ batch-service/Makefile | 5 +++++ batch-service/cmd/main.go | 5 +++-- batch-service/cmd/usecase/article.go | 5 +++++ batch-service/cmd/usecase/rss.go | 21 ++++++++++----------- batch-service/server/main.go | 3 ++- 6 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 batch-service/.golangci.yml create mode 100644 batch-service/Makefile diff --git a/batch-service/.golangci.yml b/batch-service/.golangci.yml new file mode 100644 index 00000000..6a514fb4 --- /dev/null +++ b/batch-service/.golangci.yml @@ -0,0 +1,13 @@ +linters-settings: + govet: + check-shadowing: true + golint: + min-confidence: 0.8 +linters: + enable: + - govet + - unused + # - gocritic + - staticcheck + - stylecheck + - errcheck \ No newline at end of file diff --git a/batch-service/Makefile b/batch-service/Makefile new file mode 100644 index 00000000..019984c9 --- /dev/null +++ b/batch-service/Makefile @@ -0,0 +1,5 @@ +empty: + echo "empty" + +lint: + golangci-lint run ./... \ No newline at end of file diff --git a/batch-service/cmd/main.go b/batch-service/cmd/main.go index ad8abaec..ebfc386d 100644 --- a/batch-service/cmd/main.go +++ b/batch-service/cmd/main.go @@ -24,9 +24,10 @@ func main() { return } defer func(client *firestore.Client) { - err := client.Close() + err = client.Close() if err != nil { - + log.Fatalf("Failed to close client: %v", err) + return } }(client) diff --git a/batch-service/cmd/usecase/article.go b/batch-service/cmd/usecase/article.go index 27191f6a..9c267302 100644 --- a/batch-service/cmd/usecase/article.go +++ b/batch-service/cmd/usecase/article.go @@ -39,8 +39,13 @@ func (au *ArticleUsecase) CreateArticles(ctx context.Context, client *firestore. for _, p := range platforms { var wg sync.WaitGroup rss, err := GetRSS(p.RssURL) + if err != nil { + log.Printf("【error get rss】: %s", p.Name) + continue + } articles, err := au.ar.GetArticlesByPlatform(ctx, p.ID) if err != nil { + log.Printf("【error get articles by platform】: %s", p.Name) continue } if err != nil { diff --git a/batch-service/cmd/usecase/rss.go b/batch-service/cmd/usecase/rss.go index 63a05a18..80bee6d5 100644 --- a/batch-service/cmd/usecase/rss.go +++ b/batch-service/cmd/usecase/rss.go @@ -3,7 +3,6 @@ package usecase import ( "fmt" "github.com/Songmu/go-httpdate" - goose "github.com/advancedlogic/GoOse" "github.com/mmcdole/gofeed" "github.com/otiai10/opengraph" ) @@ -63,13 +62,13 @@ func getOGPImage(url string) (string, error) { return "", nil } -func getMetaData(url string) (faviconURL, ogpImageURL string, err error) { - g := goose.New() - article, err := g.ExtractFromURL(url) - if err != nil { - return "", "", err - } - faviconURL = article.MetaFavicon - ogpImageURL = article.TopImage - return faviconURL, ogpImageURL, nil -} +//func getMetaData(url string) (faviconURL, ogpImageURL string, err error) { +// g := goose.New() +// article, err := g.ExtractFromURL(url) +// if err != nil { +// return "", "", err +// } +// faviconURL = article.MetaFavicon +// ogpImageURL = article.TopImage +// return faviconURL, ogpImageURL, nil +//} diff --git a/batch-service/server/main.go b/batch-service/server/main.go index 48e74643..1184996a 100644 --- a/batch-service/server/main.go +++ b/batch-service/server/main.go @@ -41,7 +41,8 @@ func main() { defer func(client *firestore.Client) { err := client.Close() if err != nil { - + log.Fatalf("Failed to close client: %v", err) + return } }(client)