Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: linter #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/db/seeders/user_seeder.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}

func (userSeeder *UserSeeder) SetUsers() {
users := map[int]map[string]string{
users := map[int64]map[string]string{
1: {
"email": "[email protected]",
"name": "user1",
Expand All @@ -33,7 +33,7 @@
userSeeder.DB.First(&user, key)

if user.ID == 0 {
user.ID = uint(key)
user.ID = key

Check failure on line 36 in internal/db/seeders/user_seeder.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use key (variable of type int64) as uint value in assignment (typecheck)

Check failure on line 36 in internal/db/seeders/user_seeder.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use key (variable of type int64) as uint value in assignment) (typecheck)

Check failure on line 36 in internal/db/seeders/user_seeder.go

View workflow job for this annotation

GitHub Actions / Unit Tests

cannot use key (variable of type int64) as uint value in assignment

Check failure on line 36 in internal/db/seeders/user_seeder.go

View workflow job for this annotation

GitHub Actions / Run govulncheck

cannot use key (variable of type int64) as uint value in assignment
user.Email = value["email"]
user.Name = value["name"]
user.Password = value["password"]
Expand Down
2 changes: 1 addition & 1 deletion internal/models/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ type Post struct {
gorm.Model
Title string `json:"title" gorm:"type:text"`
Content string `json:"content" gorm:"type:text"`
UserID uint
UserID int64
User User `gorm:"foreignkey:UserID"`
}
2 changes: 1 addition & 1 deletion internal/responses/posts_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Title string `json:"title" example:"Echo"`
Content string `json:"content" example:"Echo is nice!"`
Username string `json:"username" example:"John Doe"`
ID uint `json:"id" example:"1"`
ID int64 `json:"id" example:"1"`
}

func NewPostResponse(posts []models.Post) *[]PostResponse {
Expand All @@ -19,7 +19,7 @@
Title: posts[i].Title,
Content: posts[i].Content,
Username: posts[i].User.Name,
ID: posts[i].ID,

Check failure on line 22 in internal/responses/posts_response.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use posts[i].ID (variable of type uint) as int64 value in struct literal (typecheck)

Check failure on line 22 in internal/responses/posts_response.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use posts[i].ID (variable of type uint) as int64 value in struct literal) (typecheck)

Check failure on line 22 in internal/responses/posts_response.go

View workflow job for this annotation

GitHub Actions / Unit Tests

cannot use posts[i].ID (variable of type uint) as int64 value in struct literal

Check failure on line 22 in internal/responses/posts_response.go

View workflow job for this annotation

GitHub Actions / Run govulncheck

cannot use posts[i].ID (variable of type uint) as int64 value in struct literal
})
}

Expand Down
6 changes: 3 additions & 3 deletions internal/services/token/create_access_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
func (tokenService *Service) CreateAccessToken(user *models.User) (t string, expired int64, err error) {
exp := time.Now().Add(time.Hour * ExpireCount)
claims := &JwtCustomClaims{
user.Name,
user.ID,
jwt.RegisteredClaims{
Name: user.Name,
ID: user.ID,

Check failure on line 14 in internal/services/token/create_access_token.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use user.ID (variable of type uint) as int64 value in struct literal

Check failure on line 14 in internal/services/token/create_access_token.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use user.ID (variable of type uint) as int64 value in struct literal

Check failure on line 14 in internal/services/token/create_access_token.go

View workflow job for this annotation

GitHub Actions / Unit Tests

cannot use user.ID (variable of type uint) as int64 value in struct literal

Check failure on line 14 in internal/services/token/create_access_token.go

View workflow job for this annotation

GitHub Actions / Run govulncheck

cannot use user.ID (variable of type uint) as int64 value in struct literal
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(exp),
},
}
Expand Down
4 changes: 2 additions & 2 deletions internal/services/token/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ const ExpireRefreshCount = 168

type JwtCustomClaims struct {
Name string `json:"name"`
ID uint `json:"id"`
ID int64 `json:"id"`
jwt.RegisteredClaims
}

type JwtCustomRefreshClaims struct {
ID uint `json:"id"`
ID int64 `json:"id"`
jwt.RegisteredClaims
}

Expand Down
Loading