From f9348ea9b152ab34697dd2fc82ed74492b3454d7 Mon Sep 17 00:00:00 2001 From: "David R. Jenni" Date: Wed, 1 Mar 2017 12:41:02 +0100 Subject: [PATCH] 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 --- present/code.go | 41 ----------------------------------------- present/code_test.go | 1 - 2 files changed, 42 deletions(-) diff --git a/present/code.go b/present/code.go index 67a79dba..b47a72a5 100644 --- a/present/code.go +++ b/present/code.go @@ -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) -} diff --git a/present/code_test.go b/present/code_test.go index f180ea30..b01a4e31 100644 --- a/present/code_test.go +++ b/present/code_test.go @@ -55,7 +55,6 @@ func main() { // HLfunc name string readFile func(string) ([]byte, error) sourceFile string - sourceLine int cmd string err string Code