chore: reformat code & removed unnecessary log statements

Signed-off-by: SoXX <soxx@fenpa.ws>
This commit is contained in:
SoXX 2023-10-24 10:35:33 +02:00
parent 821462a426
commit 501dddc1c6
19 changed files with 38 additions and 48 deletions

5
go.mod
View File

@ -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
)

6
go.sum
View File

@ -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=

View File

@ -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

View File

@ -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 &note, nil

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
}

View File

@ -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(&noteResponse)
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, &notesResponse)
if err != nil {
// Log the error and return an empty slice and the error.
log.Println(err)
return nil, err
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}