flag.go
func (f *FlagSet) PrintDefaults() {
	// group together all flags for a given value
	flags := make(map[interface{}]flagsByLength)
	f.VisitAll(func(f *Flag) {
		flags[f.Value] = append(flags[f.Value], f)
	})

	// sort the output flags by shortest name for each group.
	var byName flagsByName
	for _, f := range flags {
		sort.Sort(f)
		byName = append(byName, f)
	}
	sort.Sort(byName)

	var line bytes.Buffer
	for _, fs := range byName {
		line.Reset()
		for i, f := range fs {
			if i > 0 {
				line.WriteString(", ")
			}
			line.WriteString(flagWithMinus(f.Name))
		}
		format := "%s  (= %s)\n    %s\n"
		if _, ok := fs[0].Value.(*stringValue); ok {
			// put quotes on the value
			format = "%s (= %q)\n    %s\n"
		}
		fmt.Fprintf(f.out(), format, line.Bytes(), fs[0].DefValue, fs[0].Usage)
	}
}
func (f *FlagSet) PrintDefaults() {
	// group together all flags for a given value
	flags := make(map[interface{}]flagsByLength)
	f.VisitAll(func(f *Flag) {
		flags[f.Value] = append(flags[f.Value], f)
	})

	// sort the output flags by shortest name for each group.
	var byName flagsByName
	for _, f := range flags {
		sort.Sort(f)
		byName = append(byName, f)
	}
	sort.Sort(byName)

	var line bytes.Buffer
	for _, fs := range byName {
		line.Reset()
		for i, f := range fs {
			if i > 0 {
				line.WriteString(", ")
			}
			line.WriteString(flagWithMinus(f.Name))
		}
		format := "%s  (= %s)\n    %s\n"
		if _, ok := fs[0].Value.(*stringValue); ok {
			// put quotes on the value
			format = "%s (= %q)\n    %s\n"
		}
		fmt.Fprintf(f.out(), format, line.Bytes(), fs[0].DefValue, fs[0].Usage)
	}
}
// PrintDefaults prints, to standard error unless configured
// otherwise, the default values of all defined flags in the set.
// If there is more than one name for a given flag, the usage information and
// default value from the shortest will be printed (or the least alphabetically
// if there are several equally short flag names).