Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9
with:
version: v2.1
version: v2.11.2

- name: Run tests
run: go test -race -cover -v ./...
Expand Down
14 changes: 7 additions & 7 deletions assert/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,28 +115,28 @@ func (ae *AssertionError) Format(ctx *AssertionContext) string {

// Primary and comparison values
if ae.PrimaryValue.Label != "" {
sb.WriteString(fmt.Sprintf(" %s: %s\n", ae.PrimaryValue.Label, formatValue(ae.PrimaryValue.Value)))
fmt.Fprintf(&sb, " %s: %s\n", ae.PrimaryValue.Label, formatValue(ae.PrimaryValue.Value))
}
if ae.ComparisonValue.Label != "" {
sb.WriteString(fmt.Sprintf(" %s: %s\n", ae.ComparisonValue.Label, formatValue(ae.ComparisonValue.Value)))
fmt.Fprintf(&sb, " %s: %s\n", ae.ComparisonValue.Label, formatValue(ae.ComparisonValue.Value))
}

// Error if present
if ae.Error != nil {
sb.WriteString(fmt.Sprintf(" Error: %v\n", ae.Error))
fmt.Fprintf(&sb, " Error: %v\n", ae.Error)
}

// Extra key-value pairs
for _, kv := range ae.ExtraValues {
sb.WriteString(fmt.Sprintf(" %s: %s\n", kv.Label, formatValue(kv.Value)))
fmt.Fprintf(&sb, " %s: %s\n", kv.Label, formatValue(kv.Value))
}

// Diff if present
if ae.Diff != "" {
sb.WriteString(" Diff:\n")
for line := range strings.SplitSeq(ae.Diff, "\n") {
if line != "" {
sb.WriteString(fmt.Sprintf(" %s\n", line))
fmt.Fprintf(&sb, " %s\n", line)
}
}
}
Expand All @@ -145,7 +145,7 @@ func (ae *AssertionError) Format(ctx *AssertionContext) string {
if len(ae.Details) > 0 {
sb.WriteString(" Details:\n")
for _, detail := range ae.Details {
sb.WriteString(fmt.Sprintf(" %s\n", detail))
fmt.Fprintf(&sb, " %s\n", detail)
}
}

Expand All @@ -155,7 +155,7 @@ func (ae *AssertionError) Format(ctx *AssertionContext) string {
// Add indentation for the stack block
for line := range strings.SplitSeq(ae.Stack, "\n") {
if line != "" { // Avoid adding empty lines
sb.WriteString(fmt.Sprintf(" %s\n", line))
fmt.Fprintf(&sb, " %s\n", line)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions diff/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,23 @@ func (c ContextFormatter) Format(edits []Line, options FormatOptions) string {
switch edit.Kind {
case Equal:
if options.ShowLineNumbers {
sb.WriteString(fmt.Sprintf("%4d %4d ", aLineNum, bLineNum))
fmt.Fprintf(&sb, "%4d %4d ", aLineNum, bLineNum)
} else {
sb.WriteString(" ")
}
sb.WriteString(edit.Text)
sb.WriteString("\n")
case Delete:
if options.ShowLineNumbers {
sb.WriteString(fmt.Sprintf("%4d - ", aLineNum))
fmt.Fprintf(&sb, "%4d - ", aLineNum)
} else {
sb.WriteString("- ")
}
sb.WriteString(edit.Text)
sb.WriteString("\n")
case Insert:
if options.ShowLineNumbers {
sb.WriteString(fmt.Sprintf(" %4d + ", bLineNum))
fmt.Fprintf(&sb, " %4d + ", bLineNum)
} else {
sb.WriteString("+ ")
}
Expand Down Expand Up @@ -163,7 +163,7 @@ func (u UnifiedFormatter) Format(edits []Line, options FormatOptions) string {
hunkHeader := calculateHunkHeader(edits, r)

// Format the @@ hunk header
sb.WriteString(fmt.Sprintf("@@ -%s +%s @@\n", hunkHeader.aRange, hunkHeader.bRange))
fmt.Fprintf(&sb, "@@ -%s +%s @@\n", hunkHeader.aRange, hunkHeader.bRange)

// Write Hunk Body
// Iterate through the chunk range to write the body
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/neticdk/go-stdlib

go 1.24.1
go 1.26.1

require golang.org/x/sys v0.41.0

Expand Down
2 changes: 1 addition & 1 deletion xstructs/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ func (h *handler) handleMap(obj any) any {
// handleSlice handles the conversion of a slice to a slice of any,
// recursively converting nested maps, slices and structs.
func (h *handler) handleSlice(obj any) any {
s := []any{}
val := reflect.ValueOf(obj)
s := make([]any, 0, val.Len())
for i := range val.Len() {
s = append(s, h.handle(val.Index(i).Interface()))
}
Expand Down