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

docs: add package documentation and enable stylecheck #157

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
1 change: 0 additions & 1 deletion api/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ linters:
# To fix ###############################################
- wsl
- wrapcheck
- stylecheck
- perfsprint
- noctx
- nilerr
Expand Down
2 changes: 2 additions & 0 deletions api/cache/file_cache.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package cache contains the various redis stored caches for metadata information.
//
// Copyright 2023 Anass Bouassaba.
//
// Use of this software is governed by the Business Source License
Expand Down
2 changes: 2 additions & 0 deletions api/client/language_client.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package client contains the external clients used by the API.
//
// Copyright 2023 Anass Bouassaba.
//
// Use of this software is governed by the Business Source License
Expand Down
2 changes: 2 additions & 0 deletions api/config/config.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package config contains the application configuration for the api server.
//
// Copyright 2023 Anass Bouassaba.
//
// Use of this software is governed by the Business Source License
Expand Down
2 changes: 2 additions & 0 deletions api/errorpkg/error_constants.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package errorpkg defines the various errors returned from the api.
//
// Copyright 2023 Anass Bouassaba.
//
// Use of this software is governed by the Business Source License
Expand Down
2 changes: 2 additions & 0 deletions api/guard/file_guard.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package guard contains the guards ensuring proper access validation.
//
// Copyright 2023 Anass Bouassaba.
//
// Use of this software is governed by the Business Source License
Expand Down
5 changes: 5 additions & 0 deletions api/helper/array.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package helper contains various helper functions.
//
// Copyright 2023 Anass Bouassaba.
//
// Use of this software is governed by the Business Source License
Expand All @@ -10,7 +12,10 @@

package helper

import "slices"

func Includes(arr []string, str string) bool {
slices.Contains(arr, str)
for _, v := range arr {
if v == str {
return true
Expand Down
1 change: 1 addition & 0 deletions api/infra/file_identifier.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package infra.
// Copyright 2023 Anass Bouassaba.
//
// Use of this software is governed by the Business Source License
Expand Down
2 changes: 2 additions & 0 deletions api/log/logger.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package log contains the globally used logger.
//
// Copyright 2023 Anass Bouassaba.
//
// Use of this software is governed by the Business Source License
Expand Down
2 changes: 2 additions & 0 deletions api/model/file_model.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package model contains the database models.
//
// Copyright 2023 Anass Bouassaba.
//
// Use of this software is governed by the Business Source License
Expand Down
2 changes: 2 additions & 0 deletions api/repo/file_repo.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package repo contains the repository interfaces.
//
// Copyright 2023 Anass Bouassaba.
//
// Use of this software is governed by the Business Source License
Expand Down
84 changes: 42 additions & 42 deletions api/repo/task_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,103 +41,103 @@ func (*taskEntity) TableName() string {
return "task"
}

func (o *taskEntity) BeforeCreate(*gorm.DB) (err error) {
o.CreateTime = time.Now().UTC().Format(time.RFC3339)
func (e *taskEntity) BeforeCreate(*gorm.DB) (err error) {
e.CreateTime = time.Now().UTC().Format(time.RFC3339)
return nil
}

func (o *taskEntity) BeforeSave(*gorm.DB) (err error) {
func (e *taskEntity) BeforeSave(*gorm.DB) (err error) {
timeNow := time.Now().UTC().Format(time.RFC3339)
o.UpdateTime = &timeNow
e.UpdateTime = &timeNow
return nil
}

func (p *taskEntity) GetID() string {
return p.ID
func (e *taskEntity) GetID() string {
return e.ID
}

func (p *taskEntity) GetName() string {
return p.Name
func (e *taskEntity) GetName() string {
return e.Name
}

func (p *taskEntity) GetError() *string {
return p.Error
func (e *taskEntity) GetError() *string {
return e.Error
}

func (p *taskEntity) GetPercentage() *int {
return p.Percentage
func (e *taskEntity) GetPercentage() *int {
return e.Percentage
}

func (p *taskEntity) GetIsIndeterminate() bool {
return p.IsIndeterminate
func (e *taskEntity) GetIsIndeterminate() bool {
return e.IsIndeterminate
}

func (p *taskEntity) GetUserID() string {
return p.UserID
func (e *taskEntity) GetUserID() string {
return e.UserID
}

func (p *taskEntity) GetStatus() string {
return p.Status
func (e *taskEntity) GetStatus() string {
return e.Status
}

func (s *taskEntity) GetPayload() map[string]string {
if s.Payload.String() == "" {
func (e *taskEntity) GetPayload() map[string]string {
if e.Payload.String() == "" {
return nil
}
res := map[string]string{}
if err := json.Unmarshal([]byte(s.Payload.String()), &res); err != nil {
if err := json.Unmarshal([]byte(e.Payload.String()), &res); err != nil {
log.GetLogger().Fatal(err)
return nil
}
return res
}

func (o *taskEntity) GetCreateTime() string {
return o.CreateTime
func (e *taskEntity) GetCreateTime() string {
return e.CreateTime
}

func (o *taskEntity) GetUpdateTime() *string {
return o.UpdateTime
func (e *taskEntity) GetUpdateTime() *string {
return e.UpdateTime
}

func (p *taskEntity) HasError() bool {
return p.Error != nil
func (e *taskEntity) HasError() bool {
return e.Error != nil
}

func (p *taskEntity) SetName(name string) {
p.Name = name
func (e *taskEntity) SetName(name string) {
e.Name = name
}

func (p *taskEntity) SetError(error *string) {
p.Error = error
func (e *taskEntity) SetError(error *string) {
e.Error = error
}

func (p *taskEntity) SetPercentage(percentage *int) {
p.Percentage = percentage
func (e *taskEntity) SetPercentage(percentage *int) {
e.Percentage = percentage
}

func (p *taskEntity) SetIsIndeterminate(isIndeterminate bool) {
p.IsIndeterminate = isIndeterminate
func (e *taskEntity) SetIsIndeterminate(isIndeterminate bool) {
e.IsIndeterminate = isIndeterminate
}

func (p *taskEntity) SetUserID(userID string) {
p.UserID = userID
func (e *taskEntity) SetUserID(userID string) {
e.UserID = userID
}

func (p *taskEntity) SetStatus(status string) {
p.Status = status
func (e *taskEntity) SetStatus(status string) {
e.Status = status
}

func (s *taskEntity) SetPayload(p map[string]string) {
func (e *taskEntity) SetPayload(p map[string]string) {
if p == nil {
s.Payload = nil
e.Payload = nil
} else {
b, err := json.Marshal(p)
if err != nil {
log.GetLogger().Fatal(err)
return
}
if err := s.Payload.UnmarshalJSON(b); err != nil {
if err := e.Payload.UnmarshalJSON(b); err != nil {
log.GetLogger().Fatal(err)
}
}
Expand Down
2 changes: 2 additions & 0 deletions api/router/constants.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package router contains the API routers.
//
// Copyright 2023 Anass Bouassaba.
//
// Use of this software is governed by the Business Source License
Expand Down
6 changes: 3 additions & 3 deletions api/router/snapshot_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func (r *SnapshotRouter) AppendNonJWTRoutes(g fiber.Router) {
// @Router /snapshots [get]
func (r *SnapshotRouter) List(c *fiber.Ctx) error {
var err error
fileId := c.Query("file_id")
if fileId == "" {
fileID := c.Query("file_id")
if fileID == "" {
return errorpkg.NewMissingQueryParamError("file_id")
}
var page int64
Expand Down Expand Up @@ -92,7 +92,7 @@ func (r *SnapshotRouter) List(c *fiber.Ctx) error {
if !IsValidSortOrder(sortOrder) {
return errorpkg.NewInvalidQueryParamError("sort_order")
}
res, err := r.snapshotSvc.List(fileId, service.SnapshotListOptions{
res, err := r.snapshotSvc.List(fileID, service.SnapshotListOptions{
Page: uint(page),
Size: uint(size),
SortBy: sortBy,
Expand Down
2 changes: 2 additions & 0 deletions api/search/file_search.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package search contains the implementation of the search indices.
//
// Copyright 2023 Anass Bouassaba.
//
// Use of this software is governed by the Business Source License
Expand Down
2 changes: 2 additions & 0 deletions api/service/constants.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package service contains the services of the api.
//
// Copyright 2023 Anass Bouassaba.
//
// Use of this software is governed by the Business Source License
Expand Down
1 change: 1 addition & 0 deletions api/templates/templates.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package templates contains the virtual filesystem containing the email templates.
package templates

import "embed"
Expand Down
Loading