()
| 274 | } |
| 275 | |
| 276 | func ExampleSplitCommandAndArgs() { |
| 277 | var commandLine string |
| 278 | var command string |
| 279 | var args []string |
| 280 | |
| 281 | // just for the test - change GOOS and reset it at the end of the test |
| 282 | runtimeGoos = osWindows |
| 283 | defer func() { |
| 284 | runtimeGoos = runtime.GOOS |
| 285 | }() |
| 286 | |
| 287 | commandLine = `mkdir /P "C:\Program Files"` |
| 288 | command, args, _ = SplitCommandAndArgs(commandLine) |
| 289 | |
| 290 | fmt.Printf("Windows: %s: %s [%s]\n", commandLine, command, strings.Join(args, ",")) |
| 291 | |
| 292 | // set GOOS to linux |
| 293 | runtimeGoos = osLinux |
| 294 | |
| 295 | commandLine = `mkdir -p /path/with\ space` |
| 296 | command, args, _ = SplitCommandAndArgs(commandLine) |
| 297 | |
| 298 | fmt.Printf("Linux: %s: %s [%s]\n", commandLine, command, strings.Join(args, ",")) |
| 299 | |
| 300 | // Output: |
| 301 | // Windows: mkdir /P "C:\Program Files": mkdir [/P,C:\Program Files] |
| 302 | // Linux: mkdir -p /path/with\ space: mkdir [-p,/path/with space] |
| 303 | } |
nothing calls this directly
no test coverage detected