mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
x/tools/present: remove unused code
Found with honnef.co/go/tools/cmd/unused. Change-Id: Iabfa1e9926e097ba11d1db0a2d785fec70ce3997 Reviewed-on: https://go-review.googlesource.com/37609 Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
64f598be56
commit
f9348ea9b1
@ -265,44 +265,3 @@ func parseArgs(name string, line int, args []string) (res []interface{}, err err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// parseArg returns the integer or string value of the argument and tells which it is.
|
||||
func parseArg(arg interface{}, max int) (ival int, sval string, isInt bool, err error) {
|
||||
switch n := arg.(type) {
|
||||
case int:
|
||||
if n <= 0 || n > max {
|
||||
return 0, "", false, fmt.Errorf("%d is out of range", n)
|
||||
}
|
||||
return n, "", true, nil
|
||||
case string:
|
||||
return 0, n, false, nil
|
||||
}
|
||||
return 0, "", false, fmt.Errorf("unrecognized argument %v type %T", arg, arg)
|
||||
}
|
||||
|
||||
// match identifies the input line that matches the pattern in a code invocation.
|
||||
// If start>0, match lines starting there rather than at the beginning.
|
||||
// The return value is 1-indexed.
|
||||
func match(file string, start int, lines []string, pattern string) (int, error) {
|
||||
// $ matches the end of the file.
|
||||
if pattern == "$" {
|
||||
if len(lines) == 0 {
|
||||
return 0, fmt.Errorf("%q: empty file", file)
|
||||
}
|
||||
return len(lines), nil
|
||||
}
|
||||
// /regexp/ matches the line that matches the regexp.
|
||||
if len(pattern) > 2 && pattern[0] == '/' && pattern[len(pattern)-1] == '/' {
|
||||
re, err := regexp.Compile(pattern[1 : len(pattern)-1])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
for i := start; i < len(lines); i++ {
|
||||
if re.MatchString(lines[i]) {
|
||||
return i + 1, nil
|
||||
}
|
||||
}
|
||||
return 0, fmt.Errorf("%s: no match for %#q", file, pattern)
|
||||
}
|
||||
return 0, fmt.Errorf("unrecognized pattern: %q", pattern)
|
||||
}
|
||||
|
@ -55,7 +55,6 @@ func main() { // HLfunc
|
||||
name string
|
||||
readFile func(string) ([]byte, error)
|
||||
sourceFile string
|
||||
sourceLine int
|
||||
cmd string
|
||||
err string
|
||||
Code
|
||||
|
Loading…
x
Reference in New Issue
Block a user