sego
sego copied to clipboard
Sego adds many extra cmdline flags to the packages that imports sego
hi, huichen I unconsciously found the sego package would add many extra cmdline flags to the packages that imports sego. And these flags are from testing package. The code example is like below:
//test.go
package main
import (
"flag"
"fmt"
_ "github.com/huichen/sego"
)
var logfile string
func usage() {
flag.PrintDefaults()
}
func init() {
flag.StringVar(&logfile, "logfile", "./log/log.txt", "the log file path")
}
func main() {
flag.Usage = usage
flag.Parse()
fmt.Println("app run ok")
}
run the app:
$go run test.go -help
-logfile string
the log file path (default "./log/log.txt")
-test.bench string
regular expression per path component to select benchmarks to run
-test.benchmem
print memory allocations for benchmarks
-test.benchtime duration
approximate run time for each benchmark (default 1s)
-test.blockprofile string
write a goroutine blocking profile to the named file after execution
-test.blockprofilerate int
if >= 0, calls runtime.SetBlockProfileRate() (default 1)
-test.count n
run tests and benchmarks n times (default 1)
-test.coverprofile string
write a coverage profile to the named file after execution
-test.cpu string
comma-separated list of number of CPUs to use for each test
-test.cpuprofile string
write a cpu profile to the named file during execution
-test.memprofile string
write a memory profile to the named file after execution
-test.memprofilerate int
if >=0, sets runtime.MemProfileRate
-test.outputdir string
directory in which to write profiles
-test.parallel int
maximum test parallelism (default 4)
-test.run string
regular expression to select tests and examples to run
-test.short
run smaller test suite to save time
-test.timeout duration
if positive, sets an aggregate time limit for all tests
-test.trace string
write an execution trace to the named file after execution
-test.v
verbose: print additional output
exit status 2
I did some debugging and I found the reason for this is that test_utils.go in sego imports "testing". I think it is not a good experience for sego users.
A simple approach to fix it is that renaming test_utils.go to utils_test.go. After this, the compiler will ignore the content in this file when building non-test package.