There's also Google's shlex package: 
https://pkg.go.dev/github.com/google/shlex?tab=doc

Incidentally, on Windows Go has to do this manually on startup. See 
commandLineToArgv in https://golang.org/src/os/exec_windows.go

-Ben

On Tuesday, April 21, 2020 at 4:27:41 AM UTC+12, Michał Łowicki wrote:
>
> Hi,
>
> I'm working on a program which will have a prompt to enter commands like:
>
>     add "foo bar"
>
> I need what os.Args provides but on custom input so to above input I would 
> like to get:
>
>     []string{"add", "foo bar"}
>
> Package os uses runtime_args(), and it isn't exported nor accepts input. 
> Any idea what can I use instead? As a fallback, I can always implement 
> something like https://stackoverflow.com/a/46973603, but maybe there is a 
> smarter way to do it.
>
> -- 
> BR,
> Michał Łowicki
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/bca1f192-3dee-4bcc-9b7a-eef71d51fc78%40googlegroups.com.

Reply via email to