Skip to content

Commit 04c69b1

Browse files
committed
cleanup: lint go code
at present 202 problems (51 errors) (151 warnings)
1 parent 171f921 commit 04c69b1

File tree

19 files changed

+30
-35
lines changed

19 files changed

+30
-35
lines changed

examples/golang/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ import (
66
"github.com/pyroscope-io/pyroscope/pkg/agent/profiler"
77
)
88

9-
func work(n int) {
10-
for i := 0; i < n; i++ {
9+
func work(int) {
1110

12-
}
1311
}
1412

1513
func fastFunction() {

pkg/agent/gospy/gospy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ type GoSpy struct {
2323
selfFrame *runtime.Frame
2424
}
2525

26-
func Start(_pid int) (spy.Spy, error) {
26+
func Start(_ int) (spy.Spy, error) {
2727
return &GoSpy{}, nil
2828
}
2929

30-
func (s *GoSpy) Stop() error {
30+
func (*GoSpy) Stop() error {
3131
return nil
3232
}
3333

pkg/agent/selfprofile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/sirupsen/logrus"
88
)
99

10-
func SelfProfile(cfg *config.Config, u upstream.Upstream, appName string) {
10+
func SelfProfile(_ *config.Config, u upstream.Upstream, appName string) {
1111
// TODO: add sample rate
1212
s := NewSession(u, appName, "gospy", 100, 0, false)
1313
err := s.Start()

pkg/exec/cli.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ func generateSeed(args []string) string {
195195

196196
func generateCredentialsDrop() (*syscall.Credential, error) {
197197
sudoUser := os.Getenv("SUDO_USER")
198-
sudoUid := os.Getenv("SUDO_UID")
198+
sudoUID := os.Getenv("SUDO_UID")
199199
sudoGid := os.Getenv("SUDO_GID")
200200

201-
logrus.Infof("dropping permissions, running command as %q (%s/%s)", sudoUser, sudoUid, sudoGid)
201+
logrus.Infof("dropping permissions, running command as %q (%s/%s)", sudoUser, sudoUID, sudoGid)
202202

203-
uid, err := strconv.Atoi(sudoUid)
203+
uid, err := strconv.Atoi(sudoUID)
204204
if err != nil {
205205
return nil, err
206206
}

pkg/server/controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ func renderServerError(rw http.ResponseWriter, text string) {
100100
rw.Write([]byte("\n"))
101101
}
102102

103-
type indexPageJson struct {
103+
type indexPageJSON struct {
104104
AppNames []string `json:"appNames"`
105105
}
106106

107-
type buildInfoJson struct {
107+
type bi struct {
108108
GOOS string `json:"goos"`
109109
GOARCH string `json:"goarch"`
110110
Version string `json:"version"`
@@ -121,7 +121,7 @@ type indexPage struct {
121121
ExtraMetadata string
122122
}
123123

124-
func (ctrl *Controller) renderIndexPage(dir http.FileSystem, rw http.ResponseWriter, r *http.Request) {
124+
func (ctrl *Controller) renderIndexPage(dir http.FileSystem, rw http.ResponseWriter, _ *http.Request) {
125125
f, err := dir.Open("/index.html")
126126
if err != nil {
127127
renderServerError(rw, fmt.Sprintf("could not find file index.html: %q", err))
@@ -140,7 +140,7 @@ func (ctrl *Controller) renderIndexPage(dir http.FileSystem, rw http.ResponseWri
140140
return
141141
}
142142

143-
initialStateObj := indexPageJson{}
143+
initialStateObj := indexPageJSON{}
144144
ctrl.s.GetValues("__name__", func(v string) bool {
145145
initialStateObj.AppNames = append(initialStateObj.AppNames, v)
146146
return true
@@ -152,7 +152,7 @@ func (ctrl *Controller) renderIndexPage(dir http.FileSystem, rw http.ResponseWri
152152
}
153153
initialStateStr := string(b)
154154

155-
buildInfoObj := buildInfoJson{
155+
buildInfoObj := bi{
156156
GOOS: runtime.GOOS,
157157
GOARCH: runtime.GOARCH,
158158
Version: build.Version,

pkg/server/labels.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"net/http"
66
)
77

8-
func (ctrl *Controller) labelsHandler(w http.ResponseWriter, r *http.Request) {
8+
func (ctrl *Controller) labelsHandler(w http.ResponseWriter, _ *http.Request) {
99
res := []string{}
1010
ctrl.s.GetKeys(func(k string) bool {
1111
res = append(res, k)
@@ -19,7 +19,7 @@ func (ctrl *Controller) labelsHandler(w http.ResponseWriter, r *http.Request) {
1919
w.Write(b)
2020
}
2121

22-
func (ctrl *Controller) labelValuesHandler(w http.ResponseWriter, r *http.Request) {
22+
func (ctrl *Controller) labelValuesHandler(w http.ResponseWriter, _ *http.Request) {
2323
res := []string{}
2424
labelName := r.URL.Query().Get("label")
2525
ctrl.s.GetValues(labelName, func(v string) bool {

pkg/storage/dict/trie.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ OuterLoop:
115115
continue OuterLoop
116116
} else {
117117
// 2
118-
119118
varint.Write(w, uint64(leadIndex))
120119
varint.Write(w, uint64(len(leadKey)))
121120
return

pkg/storage/dimension/serialization.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ func (s *Dimension) Serialize(w io.Writer) error {
1616

1717
for _, k := range s.keys {
1818
varint.Write(w, uint64(len(k)))
19-
w.Write([]byte(k))
19+
if err != nil {
20+
return nil
21+
} else {
22+
w.Write([]byte(k))
23+
}
2024
}
2125
return nil
2226
}

pkg/storage/labels/labels.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type Labels struct {
1111
db *badger.DB
1212
}
1313

14-
func New(cfg *config.Config, db *badger.DB) *Labels {
14+
func New(_, db *badger.DB) *Labels {
1515
ll := &Labels{
1616
db: db,
1717
}

pkg/storage/segment/segment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (sn *streeNode) findAddons() []Addon {
6666
return res
6767
}
6868

69-
func (sn *streeNode) put(st, et time.Time, samples uint64, cb func(n *streeNode, depth int, dt time.Time, r *big.Rat, addons []Addon)) {
69+
func (sn *streeNode) put(st, et time.Time, _ uint64, cb func(n *streeNode, depth int, dt time.Time, r *big.Rat, addons []Addon)) {
7070
nodes := []*streeNode{sn}
7171

7272
for len(nodes) > 0 {

0 commit comments

Comments
 (0)