Skip to content

Commit

Permalink
Fix: linter
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky authored and m-kus committed Nov 12, 2020
1 parent 678f5ea commit 2405864
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions internal/parsers/stacktrace/stacktrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package stacktrace

import (
"fmt"
"io"
"strings"

"github.com/baking-bad/bcdhub/internal/logger"
"github.com/baking-bad/bcdhub/internal/models"
)

Expand Down Expand Up @@ -148,16 +150,23 @@ func (st *StackTrace) String() string {
}
}

st.print(topLevel, 1, &builder)
if err := st.print(topLevel, 1, &builder); err != nil {
logger.Error(err)
}
return builder.String()
}

func (st *StackTrace) print(arr []int64, depth int, builder *strings.Builder) {
func (st *StackTrace) print(arr []int64, depth int, builder io.StringWriter) error {
for i := range arr {
if item, ok := st.tree[arr[i]]; ok {
builder.WriteString(strings.Repeat(" ", depth))
builder.WriteString(item.String())
if _, err := builder.WriteString(strings.Repeat(" ", depth)); err != nil {
return err
}
if _, err := builder.WriteString(item.String()); err != nil {
return err
}
st.print(item.children, depth+1, builder)
}
}
return nil
}

0 comments on commit 2405864

Please sign in to comment.