Skip to content

cleanup: max64 helper is redundant — use built-in max() (Go 1.21+) #33

Description

@gitcoder89431

Problem

internal/syncthing/client.go defines a manual max64 helper:

func max64(a, b int64) int64 {
    if a > b {
        return a
    }
    return b
}

Go 1.21 introduced built-in min and max functions that work on all ordered types including int64. This helper is dead weight.

Fix

Delete max64 and replace the two usages with the built-in:

return max(0, curIn-c.baselineIn), max(0, curOut-c.baselineOut), nil

Verify go.mod requires go 1.21 or higher (which it likely does since min() is already used in update.go and server.go).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions