asasalint

Golang linter, lint that pass any slice as any in variadic function

Install

go install github.com/alingse/asasalint/cmd/[email protected]

Usage

asasalint ./...

ignore some func that was by desgin

asasalint -e append,Append ./...

Why

two kind of unexpected usage, and go build success

package main

import "fmt"

func A(args ...any) int {
    return len(args)
}

func B(args ...any) int {
    return A(args)
}

func main() {

    // 1
    fmt.Println(B(1, 2, 3, 4))
}

package main

import "fmt"

func errMsg(msg string, args ...any) string {
    return fmt.Sprintf(msg, args...)
}

func Err(msg string, args ...any) string {
    return errMsg(msg, args)
}

func main() {

    // p1 [hello world] p2 %!s(MISSING)
    fmt.Println(Err("p1 %s p2 %s", "hello", "world"))
}

TODO

  1. add to golangci-lint
  2. given a SuggestEdition
  3. add append to default exclude ?
  4. ingore pattern fn(a, b, []any{1,2,3}) , because []any{1,2,3} is most likely by design

GitHub

View Github