github.com/powerman/golang-tools@v0.1.11-0.20220410185822-5ad214d8d803/internal/lsp/analysis/infertypeargs/infertypeargs.go (about) 1 // Copyright 2021 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Package infertypeargs defines an analyzer that checks for explicit function 6 // arguments that could be inferred. 7 package infertypeargs 8 9 import ( 10 "github.com/powerman/golang-tools/go/analysis" 11 "github.com/powerman/golang-tools/go/analysis/passes/inspect" 12 ) 13 14 const Doc = `check for unnecessary type arguments in call expressions 15 16 Explicit type arguments may be omitted from call expressions if they can be 17 inferred from function arguments, or from other type arguments: 18 19 func f[T any](T) {} 20 21 func _() { 22 f[string]("foo") // string could be inferred 23 } 24 ` 25 26 var Analyzer = &analysis.Analyzer{ 27 Name: "infertypeargs", 28 Doc: Doc, 29 Requires: []*analysis.Analyzer{inspect.Analyzer}, 30 Run: run, 31 }