Skip to content

Commit

Permalink
Added some experiments with golang linters
Browse files Browse the repository at this point in the history
  • Loading branch information
k8s4 committed Dec 1, 2024
1 parent 508e989 commit f744509
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func (storage *CarsStorage) GetCarsList(userIdFilter int64, brandFilter string,
if licenseFilter != "" {
query += fmt.Sprintf(" AND license_plate LIKE $%d", placeholderNum)
args = append(args, fmt.Sprintf("%%%s%%", licenseFilter))
placeholderNum++
}

var dbResult []userCar
Expand Down
5 changes: 0 additions & 5 deletions examples/golang/cource/06h_http/internals/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func (server *AppServer) Serve() {
if err != nil {
log.Fatalln(err)
}
return
}

func (server *AppServer) Shutdown() {
Expand All @@ -79,8 +78,4 @@ func (server *AppServer) Shutdown() {
}

log.Println("Server exited properly.")

if err == http.ErrServerClosed {
err = nil
}
}
25 changes: 25 additions & 0 deletions examples/golang/cource/06i_code_quality/.golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

output:
formats: colored-line-number
print-issued-lines: true
print-linter-name: true

linters:
enable-all: true
disable:
- stylecheck
- revive
- wsl
- gofmt
- gosimple
- gofumpt
- goimports
- nlreturn
- exportloopref
fast: false

issues:
exclude-use-default: false
max-issues-per-linter: 100
max-same-issues: 4
nes: false
6 changes: 6 additions & 0 deletions examples/golang/cource/06i_code_quality/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
install:
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.2
lint:
@golangci-lint run ./... -v
lint_autofix:
@GO111MODULE=on $(GOLINT) run ./ -v --fix
3 changes: 3 additions & 0 deletions examples/golang/cource/06i_code_quality/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module someexample

go 1.23.2
53 changes: 53 additions & 0 deletions examples/golang/cource/06i_code_quality/someexample.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package someexample

// Person -.
type Person struct {
Name string
Age int
}

// GetName blah
func (p Person) GetName() string {
return p.Name
}

type Avatar struct {
URL string
Size int64
}

// Client -.
type Client struct {
ID int64
Img Avatar
Name string
Age int64
}

// HasAvatar ===
func (c Client) HasAvatar() bool {
if c.Img.URL != "" {
return true
}
return false
}

// UpdateAvatar ...
func (c *Client) UpdateAvatar() {
c.Img.URL = "new_url"
}

// GetName -.
func (c Client) GetName() string {
return c.Name
}

//NewClient -.
func NewClient(name string, age int, img Avatar) *Client {
return &Client{
ID: 7,
Name: name,
Age: int64(age),
Img: img,
}
}

0 comments on commit f744509

Please sign in to comment.