Bumping k8s dependencies to 1.13
This commit is contained in:
77
vendor/golang.org/x/tools/go/analysis/singlechecker/singlechecker.go
generated
vendored
Normal file
77
vendor/golang.org/x/tools/go/analysis/singlechecker/singlechecker.go
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package singlechecker defines the main function for an analysis
|
||||
// driver with only a single analysis.
|
||||
// This package makes it easy for a provider of an analysis package to
|
||||
// also provide a standalone tool that runs just that analysis.
|
||||
//
|
||||
// For example, if example.org/findbadness is an analysis package,
|
||||
// all that is needed to define a standalone tool is a file,
|
||||
// example.org/findbadness/cmd/findbadness/main.go, containing:
|
||||
//
|
||||
// // The findbadness command runs an analysis.
|
||||
// package main
|
||||
//
|
||||
// import (
|
||||
// "example.org/findbadness"
|
||||
// "golang.org/x/tools/go/analysis/singlechecker"
|
||||
// )
|
||||
//
|
||||
// func main() { singlechecker.Main(findbadness.Analyzer) }
|
||||
//
|
||||
package singlechecker
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/tools/go/analysis"
|
||||
"golang.org/x/tools/go/analysis/internal/analysisflags"
|
||||
"golang.org/x/tools/go/analysis/internal/checker"
|
||||
"golang.org/x/tools/go/analysis/unitchecker"
|
||||
)
|
||||
|
||||
// Main is the main function for a checker command for a single analysis.
|
||||
func Main(a *analysis.Analyzer) {
|
||||
log.SetFlags(0)
|
||||
log.SetPrefix(a.Name + ": ")
|
||||
|
||||
analyzers := []*analysis.Analyzer{a}
|
||||
|
||||
if err := analysis.Validate(analyzers); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
checker.RegisterFlags()
|
||||
|
||||
flag.Usage = func() {
|
||||
paras := strings.Split(a.Doc, "\n\n")
|
||||
fmt.Fprintf(os.Stderr, "%s: %s\n\n", a.Name, paras[0])
|
||||
fmt.Printf("Usage: %s [-flag] [package]\n\n", a.Name)
|
||||
if len(paras) > 1 {
|
||||
fmt.Println(strings.Join(paras[1:], "\n\n"))
|
||||
}
|
||||
fmt.Println("\nFlags:")
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
analyzers = analysisflags.Parse(analyzers, false)
|
||||
|
||||
args := flag.Args()
|
||||
if len(args) == 0 {
|
||||
flag.Usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(args) == 1 && strings.HasSuffix(args[0], ".cfg") {
|
||||
unitchecker.Run(args[0], analyzers)
|
||||
panic("unreachable")
|
||||
}
|
||||
|
||||
os.Exit(checker.Run(args, analyzers))
|
||||
}
|
Reference in New Issue
Block a user