From 501dddc1c65dbbc94f688bbc3ce4517a29b2379a Mon Sep 17 00:00:00 2001 From: SoXX Date: Tue, 24 Oct 2023 10:35:33 +0200 Subject: [PATCH] chore: reformat code & removed unnecessary log statements Signed-off-by: SoXX --- go.mod | 5 ++--- go.sum | 6 ++++-- pkg/e621/builder/favorite.go | 3 +-- pkg/e621/builder/note.go | 3 +-- pkg/e621/builder/notes.go | 3 +-- pkg/e621/builder/pool.go | 3 +-- pkg/e621/builder/pools.go | 3 +-- pkg/e621/builder/post.go | 3 +-- pkg/e621/builder/posts.go | 3 +-- pkg/e621/builder/tag.go | 3 +-- pkg/e621/builder/tags.go | 3 +-- pkg/e621/builder/user.go | 3 +-- pkg/e621/builder/users.go | 3 +-- pkg/e621/endpoints/favorite.go | 2 +- pkg/e621/endpoints/note.go | 8 ++++---- pkg/e621/endpoints/pool.go | 8 ++++---- pkg/e621/endpoints/post.go | 8 ++++---- pkg/e621/endpoints/tag.go | 8 ++++---- pkg/e621/endpoints/user.go | 8 ++++---- 19 files changed, 38 insertions(+), 48 deletions(-) diff --git a/go.mod b/go.mod index 9f3b86f..7c5c99d 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module git.dragse.it/anthrove/e621-to-graph go 1.21.3 require ( - github.com/google/go-cmp v0.6.0 // indirect - github.com/jarcoal/httpmock v1.3.1 // indirect - github.com/joho/godotenv v1.5.1 // indirect + github.com/jarcoal/httpmock v1.3.1 + github.com/joho/godotenv v1.5.1 ) diff --git a/go.sum b/go.sum index d98f698..d380c0b 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,8 @@ -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww= github.com/jarcoal/httpmock v1.3.1/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/maxatome/go-testdeep v1.12.0 h1:Ql7Go8Tg0C1D/uMMX59LAoYK7LffeJQ6X2T04nTH68g= +github.com/maxatome/go-testdeep v1.12.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwUBUAfUNvrclaNM= diff --git a/pkg/e621/builder/favorite.go b/pkg/e621/builder/favorite.go index 89a47c5..9500d5f 100644 --- a/pkg/e621/builder/favorite.go +++ b/pkg/e621/builder/favorite.go @@ -3,7 +3,6 @@ package builder import ( "git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints" "git.dragse.it/anthrove/e621-to-graph/pkg/e621/model" - "log" "strconv" ) @@ -38,7 +37,7 @@ func (g getFavorites) SetLimit(limitFavorites int) FavoritesBuilder { func (g getFavorites) Execute() ([]model.Post, error) { favorites, err := endpoints.GetFavorites(g.requestContext, g.query) if err != nil { - log.Println(err) + return nil, err } return favorites, nil diff --git a/pkg/e621/builder/note.go b/pkg/e621/builder/note.go index e3fad17..090c056 100644 --- a/pkg/e621/builder/note.go +++ b/pkg/e621/builder/note.go @@ -3,7 +3,6 @@ package builder import ( "git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints" "git.dragse.it/anthrove/e621-to-graph/pkg/e621/model" - "log" "strconv" ) @@ -30,7 +29,7 @@ func (g *getNote) SetNoteID(noteID int) NoteBuilder { func (g *getNote) Execute() (*model.Note, error) { note, err := endpoints.GetNote(g.requestContext, strconv.Itoa(g.noteID)) if err != nil { - log.Println(err) + return nil, err } return ¬e, nil diff --git a/pkg/e621/builder/notes.go b/pkg/e621/builder/notes.go index b3b1a4a..2d55dee 100644 --- a/pkg/e621/builder/notes.go +++ b/pkg/e621/builder/notes.go @@ -3,7 +3,6 @@ package builder import ( "git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints" "git.dragse.it/anthrove/e621-to-graph/pkg/e621/model" - "log" "strconv" ) @@ -68,7 +67,7 @@ func (g getNotes) SetLimit(limitNotes int) NotesBuilder { func (g getNotes) Execute() ([]model.Note, error) { notes, err := endpoints.GetNotes(g.requestContext, g.query) if err != nil { - log.Println(err) + return nil, err } return notes, nil diff --git a/pkg/e621/builder/pool.go b/pkg/e621/builder/pool.go index c0fabd1..b8a1e53 100644 --- a/pkg/e621/builder/pool.go +++ b/pkg/e621/builder/pool.go @@ -3,7 +3,6 @@ package builder import ( "git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints" "git.dragse.it/anthrove/e621-to-graph/pkg/e621/model" - "log" "strconv" ) @@ -29,7 +28,7 @@ func (g getPool) ID(poolID int) PoolBuilder { func (g getPool) Execute() (model.Pool, error) { pool, err := endpoints.GetPool(g.requestContext, strconv.Itoa(g.id)) if err != nil { - log.Println(err) + return model.Pool{}, err } return pool, nil diff --git a/pkg/e621/builder/pools.go b/pkg/e621/builder/pools.go index a65c985..ab8ff24 100644 --- a/pkg/e621/builder/pools.go +++ b/pkg/e621/builder/pools.go @@ -3,7 +3,6 @@ package builder import ( "git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints" "git.dragse.it/anthrove/e621-to-graph/pkg/e621/model" - "log" "strconv" ) @@ -80,7 +79,7 @@ func (g *getPools) SetLimit(limitUser int) PoolsBuilder { func (g *getPools) Execute() ([]model.Pool, error) { pools, err := endpoints.GetPools(g.requestContext, g.query) if err != nil { - log.Println(err) + return nil, err } return pools, nil diff --git a/pkg/e621/builder/post.go b/pkg/e621/builder/post.go index 6c9dec6..4213427 100644 --- a/pkg/e621/builder/post.go +++ b/pkg/e621/builder/post.go @@ -3,7 +3,6 @@ package builder import ( "git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints" "git.dragse.it/anthrove/e621-to-graph/pkg/e621/model" - "log" "strconv" ) @@ -29,7 +28,7 @@ func (g *getPost) SetPostID(postID int) PostBuilder { func (g *getPost) Execute() (*model.Post, error) { post, err := endpoints.GetPost(g.requestContext, strconv.Itoa(g.postID)) if err != nil { - log.Println(err) + return nil, err } return &post, nil diff --git a/pkg/e621/builder/posts.go b/pkg/e621/builder/posts.go index 5171edc..b52a3cd 100644 --- a/pkg/e621/builder/posts.go +++ b/pkg/e621/builder/posts.go @@ -3,7 +3,6 @@ package builder import ( "git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints" "git.dragse.it/anthrove/e621-to-graph/pkg/e621/model" - "log" "strconv" ) @@ -50,7 +49,7 @@ func (g *getPosts) SetLimit(limitUser int) PostsBuilder { func (g *getPosts) Execute() ([]model.Post, error) { posts, err := endpoints.GetPosts(g.requestContext, g.query) if err != nil { - log.Println(err) + return nil, err } return posts, err diff --git a/pkg/e621/builder/tag.go b/pkg/e621/builder/tag.go index 3a55cdb..055a17d 100644 --- a/pkg/e621/builder/tag.go +++ b/pkg/e621/builder/tag.go @@ -3,7 +3,6 @@ package builder import ( "git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints" "git.dragse.it/anthrove/e621-to-graph/pkg/e621/model" - "log" "strconv" ) @@ -29,7 +28,7 @@ func (g *getTag) SetTagID(tagID int) TagBuilder { func (g *getTag) Execute() (model.Tag, error) { tag, err := endpoints.GetTag(g.requestContext, strconv.Itoa(g.tagID)) if err != nil { - log.Println(err) + return model.Tag{}, err } return tag, nil diff --git a/pkg/e621/builder/tags.go b/pkg/e621/builder/tags.go index 62cb8e5..1a78e39 100644 --- a/pkg/e621/builder/tags.go +++ b/pkg/e621/builder/tags.go @@ -3,7 +3,6 @@ package builder import ( "git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints" "git.dragse.it/anthrove/e621-to-graph/pkg/e621/model" - "log" "strconv" ) @@ -71,7 +70,7 @@ func (g *getTags) SetLimit(limitUser int) TagsBuilder { func (g *getTags) Execute() ([]model.Tag, error) { tags, err := endpoints.GetTags(g.requestContext, g.query) if err != nil { - log.Println(err) + return nil, err } return tags, err diff --git a/pkg/e621/builder/user.go b/pkg/e621/builder/user.go index fa973b2..ba92bd3 100644 --- a/pkg/e621/builder/user.go +++ b/pkg/e621/builder/user.go @@ -3,7 +3,6 @@ package builder import ( "git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints" "git.dragse.it/anthrove/e621-to-graph/pkg/e621/model" - "log" ) type UserBuilder interface { @@ -28,7 +27,7 @@ func (g *getUser) SetUsername(username string) UserBuilder { func (g *getUser) Execute() (*model.User, error) { user, err := endpoints.GetUser(g.requestContext, g.username) if err != nil { - log.Println(err) + return nil, err } return &user, nil diff --git a/pkg/e621/builder/users.go b/pkg/e621/builder/users.go index 6c974cf..c083801 100644 --- a/pkg/e621/builder/users.go +++ b/pkg/e621/builder/users.go @@ -3,7 +3,6 @@ package builder import ( "git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints" "git.dragse.it/anthrove/e621-to-graph/pkg/e621/model" - "log" "strconv" ) @@ -35,7 +34,7 @@ func (g *getUsers) SetLimit(limitUser int) UsersBuilder { func (g *getUsers) Execute() ([]model.User, error) { users, err := endpoints.GetUsers(g.requestContext, g.query) if err != nil { - log.Println(err) + return nil, err } return users, nil diff --git a/pkg/e621/endpoints/favorite.go b/pkg/e621/endpoints/favorite.go index 1469d20..a3dcdb4 100644 --- a/pkg/e621/endpoints/favorite.go +++ b/pkg/e621/endpoints/favorite.go @@ -57,7 +57,7 @@ func GetFavorites(requestContext model.RequestContext, query map[string]string) err = json.NewDecoder(resp.Body).Decode(&favoriteResponse) if err != nil { // Log the error and return an empty User struct and the error. - log.Println(err) + return nil, err } diff --git a/pkg/e621/endpoints/note.go b/pkg/e621/endpoints/note.go index c99c7d1..b30ba2e 100644 --- a/pkg/e621/endpoints/note.go +++ b/pkg/e621/endpoints/note.go @@ -25,7 +25,7 @@ func GetNote(requestContext model.RequestContext, ID string) (model.Note, error) r, err := http.NewRequest("GET", fmt.Sprintf("%s/notes/%s.json", requestContext.Host, ID), nil) if err != nil { // Log the error and return an empty Note struct and the error. - log.Println(err) + return model.Note{}, err } @@ -37,7 +37,7 @@ func GetNote(requestContext model.RequestContext, ID string) (model.Note, error) resp, err := requestContext.Client.Do(r) if err != nil { // Log the error and return an empty Note struct and the error. - log.Println(err) + return model.Note{}, err } @@ -54,7 +54,7 @@ func GetNote(requestContext model.RequestContext, ID string) (model.Note, error) err = json.NewDecoder(resp.Body).Decode(¬eResponse) if err != nil { // Log the error and return an empty Note struct and the error. - log.Println(err) + return model.Note{}, err } @@ -113,7 +113,7 @@ func GetNotes(requestContext model.RequestContext, query map[string]string) ([]m err = json.Unmarshal(respBodyBytes, ¬esResponse) if err != nil { // Log the error and return an empty slice and the error. - log.Println(err) + return nil, err } diff --git a/pkg/e621/endpoints/pool.go b/pkg/e621/endpoints/pool.go index a00d6d2..17a2466 100644 --- a/pkg/e621/endpoints/pool.go +++ b/pkg/e621/endpoints/pool.go @@ -23,7 +23,7 @@ func GetPool(requestContext model.RequestContext, ID string) (model.Pool, error) r, err := http.NewRequest("GET", fmt.Sprintf("%s/pools/%s.json", requestContext.Host, ID), nil) if err != nil { // Log the error and return an empty Pool struct and the error. - log.Println(err) + return model.Pool{}, err } @@ -35,7 +35,7 @@ func GetPool(requestContext model.RequestContext, ID string) (model.Pool, error) resp, err := requestContext.Client.Do(r) if err != nil { // Log the error and return an empty Pool struct and the error. - log.Println(err) + return model.Pool{}, err } @@ -52,7 +52,7 @@ func GetPool(requestContext model.RequestContext, ID string) (model.Pool, error) err = json.NewDecoder(resp.Body).Decode(&poolResponse) if err != nil { // Log the error and return an empty Pool struct and the error. - log.Println(err) + return model.Pool{}, err } @@ -106,7 +106,7 @@ func GetPools(requestContext model.RequestContext, query map[string]string) ([]m err = json.NewDecoder(resp.Body).Decode(&poolsResponse) if err != nil { // Log the error and return an empty slice and the error. - log.Println(err) + return nil, err } diff --git a/pkg/e621/endpoints/post.go b/pkg/e621/endpoints/post.go index 19e69e1..ff182cc 100644 --- a/pkg/e621/endpoints/post.go +++ b/pkg/e621/endpoints/post.go @@ -22,7 +22,7 @@ func GetPost(requestContext model.RequestContext, ID string) (model.Post, error) r, err := http.NewRequest("GET", fmt.Sprintf("%s/posts/%s.json", requestContext.Host, ID), nil) if err != nil { // Log the error and return an empty Post struct and the error. - log.Println(err) + return model.Post{}, err } @@ -34,7 +34,7 @@ func GetPost(requestContext model.RequestContext, ID string) (model.Post, error) resp, err := requestContext.Client.Do(r) if err != nil { // Log the error and return an empty Post struct and the error. - log.Println(err) + return model.Post{}, err } @@ -51,7 +51,7 @@ func GetPost(requestContext model.RequestContext, ID string) (model.Post, error) err = json.NewDecoder(resp.Body).Decode(&postResponse) if err != nil { // Log the error and return an empty Post struct and the error. - log.Println(err) + return model.Post{}, err } @@ -105,7 +105,7 @@ func GetPosts(requestContext model.RequestContext, query map[string]string) ([]m err = json.NewDecoder(resp.Body).Decode(&postResponse) if err != nil { // Log the error and return an empty slice and the error. - log.Println(err) + return nil, err } diff --git a/pkg/e621/endpoints/tag.go b/pkg/e621/endpoints/tag.go index 293c644..a30c4da 100644 --- a/pkg/e621/endpoints/tag.go +++ b/pkg/e621/endpoints/tag.go @@ -23,7 +23,7 @@ func GetTag(requestContext model.RequestContext, ID string) (model.Tag, error) { r, err := http.NewRequest("GET", fmt.Sprintf("%s/tags/%s.json", requestContext.Host, ID), nil) if err != nil { // Log the error and return an empty Tag struct and the error. - log.Println(err) + return model.Tag{}, err } @@ -35,7 +35,7 @@ func GetTag(requestContext model.RequestContext, ID string) (model.Tag, error) { resp, err := requestContext.Client.Do(r) if err != nil { // Log the error and return an empty Tag struct and the error. - log.Println(err) + return model.Tag{}, err } @@ -52,7 +52,7 @@ func GetTag(requestContext model.RequestContext, ID string) (model.Tag, error) { err = json.NewDecoder(resp.Body).Decode(&tag) if err != nil { // Log the error and return an empty Tag struct and the error. - log.Println(err) + return model.Tag{}, err } @@ -117,7 +117,7 @@ func GetTags(requestContext model.RequestContext, query map[string]string) ([]mo err = json.NewDecoder(resp.Body).Decode(&tags) if err != nil { // Log the error and return an empty slice and the error. - log.Println(err) + return []model.Tag{}, err } diff --git a/pkg/e621/endpoints/user.go b/pkg/e621/endpoints/user.go index 1f4a1d4..b34cbb8 100644 --- a/pkg/e621/endpoints/user.go +++ b/pkg/e621/endpoints/user.go @@ -23,7 +23,7 @@ func GetUser(requestContext model.RequestContext, username string) (model.User, r, err := http.NewRequest("GET", fmt.Sprintf("%s/users/%s.json", requestContext.Host, username), nil) if err != nil { // Log the error and return an empty User struct and the error. - log.Println(err) + return model.User{}, err } @@ -35,7 +35,7 @@ func GetUser(requestContext model.RequestContext, username string) (model.User, resp, err := requestContext.Client.Do(r) if err != nil { // Log the error and return an empty User struct and the error. - log.Println(err) + return model.User{}, err } @@ -52,7 +52,7 @@ func GetUser(requestContext model.RequestContext, username string) (model.User, err = json.NewDecoder(resp.Body).Decode(&user) if err != nil { // Log the error and return an empty User struct and the error. - log.Println(err) + return model.User{}, err } @@ -106,7 +106,7 @@ func GetUsers(requestContext model.RequestContext, query map[string]string) ([]m err = json.NewDecoder(resp.Body).Decode(&users) if err != nil { // Log the error and return an empty slice and the error. - log.Println(err) + return []model.User{}, err }