exptostd

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

README

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

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

Documentation

Overview

Package exptostd It is an analyzer that detects functions from golang.org/x/exp/ that can be replaced by std functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAnalyzer

func NewAnalyzer() *analysis.Analyzer

NewAnalyzer create a new Analyzer.

Types

type Result added in v0.3.0

type Result struct {
	Diagnostics []analysis.Diagnostic
	// contains filtered or unexported fields
}

Result is step analysis results.

Directories

Path Synopsis
cmd
exptostd
Package main contains the basic runnable version of the linter.
Package main contains the basic runnable version of the linter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL