Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sego adds many extra cmdline flags to the packages that imports sego #25

Open
bigwhite opened this issue Dec 4, 2016 · 0 comments
Open

Comments

@bigwhite
Copy link

bigwhite commented Dec 4, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant