Skip to content

Commit

Permalink
Workflow: fix golangci-lint version
Browse files Browse the repository at this point in the history
Also fix all linter issues
  • Loading branch information
mougams committed Jan 22, 2025
1 parent beb1e9a commit b67d98b
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v6.2.0
version: v1.63.4
3 changes: 1 addition & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"

Expand Down Expand Up @@ -63,7 +62,7 @@ func GetConfig() Config {
cfg.Memory = memory.DefaultConfig

if *configFileFlag != "" {
f, err := ioutil.ReadFile(*configFileFlag)
f, err := os.ReadFile(*configFileFlag)
if err != nil {
log.Fatal(err)
}
Expand Down
21 changes: 18 additions & 3 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,21 @@ func (s *Server) Serve() error {
return
}

json.NewEncoder(w).Encode(events)
err = json.NewEncoder(w).Encode(events)
if err != nil {
log.Errorf("encoding error %s", err)
http.Error(w, err.Error(), 500)
return
}
})

s.router.GET("/filter-entries", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
json.NewEncoder(w).Encode(s.services.FilterEntries())
err := json.NewEncoder(w).Encode(s.services.FilterEntries())
if err != nil {
log.Errorf("encoding error %s", err)
http.Error(w, err.Error(), 500)
return
}
})

s.router.GET("/ws", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
Expand All @@ -97,7 +107,12 @@ func (s *Server) Serve() error {
})

s.router.GET("/status", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
w.Write([]byte("OK"))
_, err := w.Write([]byte("OK"))
if err != nil {
log.Errorf("/status error %s", err)
http.Error(w, err.Error(), 500)
return
}
})

s.router.GET("/metrics", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
Expand Down
5 changes: 4 additions & 1 deletion storage/distributed.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ func (s *Distributed) lockLoop() {
case <-s.stop:
atomic.StoreUint32(&s.enabled, 0)
log.Info("unlocking storage lock")
lock.Unlock()
err := lock.Unlock()
if err != nil {
log.Error(err)
}
s.done.Done()
return
}
Expand Down
2 changes: 0 additions & 2 deletions storage/memory/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
)

type Storage struct {
cfg Config

events []tl.Event
next int
size int
Expand Down
8 changes: 4 additions & 4 deletions storage/memory/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ func TestWrap(t *testing.T) {

s := New(Config{MaxSize: 3})

s.Store(tl.Event{ID: 1})
s.Store(tl.Event{ID: 2})
s.Store(tl.Event{ID: 3})
s.Store(tl.Event{ID: 4})
_ = s.Store(tl.Event{ID: 1})
_ = s.Store(tl.Event{ID: 2})
_ = s.Store(tl.Event{ID: 3})
_ = s.Store(tl.Event{ID: 4})

require.Equal(t,
[]tl.Event{
Expand Down
2 changes: 1 addition & 1 deletion timeline/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type Event struct {
ID int32 `json:"-"`

Time time.Time `json:"time,omitempty"`
Datacenter string `json:"datacenter,omuitempty"`
Datacenter string `json:"datacenter,omitempty"`

NodeName string `json:"node_name,omitempty"`
NodeIP string `json:"node_ip,omitempty"`
Expand Down

0 comments on commit b67d98b

Please sign in to comment.