(s string)
| 174 | } |
| 175 | |
| 176 | func Dedent(s string) string { |
| 177 | lines := strings.Split(s, "\n") |
| 178 | minIndent := -1 |
| 179 | |
| 180 | for _, l := range lines { |
| 181 | if len(l) == 0 { |
| 182 | continue |
| 183 | } |
| 184 | |
| 185 | indent := len(l) - len(strings.TrimLeft(l, " ")) |
| 186 | if minIndent == -1 || indent < minIndent { |
| 187 | minIndent = indent |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | if minIndent <= 0 { |
| 192 | return s |
| 193 | } |
| 194 | |
| 195 | var buf bytes.Buffer |
| 196 | for _, l := range lines { |
| 197 | fmt.Fprintln(&buf, strings.TrimPrefix(l, strings.Repeat(" ", minIndent))) |
| 198 | } |
| 199 | return strings.TrimSuffix(buf.String(), "\n") |
| 200 | } |
| 201 | |
| 202 | func filterFlagSet(f pflag.FlagSet, flagsToDisplay []string) pflag.FlagSet { |
| 203 | filteredFlags := pflag.NewFlagSet("flags", pflag.ContinueOnError) |
no test coverage detected