func PrintHelp() {
    fs := setupFlags(&options{})
    fs.Usage()
}
Print a help message to standard error. See constants CommandLineHelpUsage
and CommandLineHelpFooter.
package main
import (
    "strings"
    "flag"
    "fmt"
    "os"
)
var (
    CommandLineHelpUsage = `gospec [-v] [-test=PATTERN] [ROOT [PATTERN ...]]`
    CommandLineHelpFooter = `Spec files must end with a suffix "_spec.go".`
)
type options struct {
    Root        string
    TestPattern string
    SpecPattern string
    Verbose     bool
}
func setupFlags(opt *options) *flag.FlagSet {
    fs := flag.NewFlagSet("gospec", flag.ExitOnError)
    fs.BoolVar(&(opt.Verbose), "v", false, "Verbose program output.")
    fs.StringVar(&(opt.Root), "root", "./spec", "Directory containing spec files.")
    fs.StringVar(&(opt.TestPattern), "test", ".*", "Regexp matching tests to run.")
    fs.StringVar(&(opt.SpecPattern), "spec", ".*", "Regexp matching tests to run.")
    setupUsage(fs)
    return fs
}
func verifyFlags(opt *options, fs *flag.FlagSet) {
    args := fs.Args()
    if len(args) > 0 {
        opt.Root = args[0]
        args = args[1:]
    }
    if len(args) > 0 {
        patterns := make([]string, len(args))
        for i := range args {
            patterns[i] = fmt.Sprintf("(%s)", args[i])
        }
        opt.SpecPattern = strings.Join(patterns, "|")
    }
}