Skip to content

Latest commit

 

History

History
116 lines (89 loc) · 1.54 KB

readme.md

File metadata and controls

116 lines (89 loc) · 1.54 KB

ExpToStd

Detects functions from golang.org/x/exp/ that can be replaced by std functions.

Sponsor

Actual detections:

  • golang.org/x/exp/maps:

    • Keys
    • Values
    • Equal
    • EqualFunc
    • Clone
    • Copy
    • DeleteFunc
    • Clear
  • golang.org/x/exp/slices:

    • Equal
    • EqualFunc
    • Compare
    • CompareFunc
    • Index
    • IndexFunc
    • Contains
    • ContainsFunc
    • Insert
    • Delete
    • DeleteFunc
    • Replace
    • Clone
    • Compact
    • CompactFunc
    • Grow
    • Clip
    • Reverse
    • Sort
    • SortFunc
    • SortStableFunc
    • IsSorted
    • IsSortedFunc
    • Min
    • MinFunc
    • Max
    • MaxFunc
    • BinarySearch
    • BinarySearchFunc
  • golang.org/x/exp/constraints:

    • Ordered

Usages

Inside golangci-lint

Recommended.

linters:
  enable:
    - exptostd

As a CLI

go install github.com/ldez/exptostd/cmd/exptostd@latest
./exptostd ./...

Examples

package foo

import (
	"fmt"

	"golang.org/x/exp/maps"
)

func foo(m map[string]string) {
	clone := maps.Clone(m)

	fmt.Println(clone)
}

It can be replaced by:

package foo

import (
	"fmt"
	"maps"
)

func foo(m map[string]string) {
	clone := maps.Clone(m)

	fmt.Println(clone)
}

References