Re: [go-nuts] input directly from cli after a function

2025-02-13 Thread Jason E. Aten
If you want to mix flags and "unflagged" arguments, like your integer, see the flag package. "After parsing, the arguments following the flags are available as the slice flag.Args or individually as flag.Arg(i). The arguments are indexed from 0 through flag.NArg-1." https://pkg.go.dev/flag Yo

Re: [go-nuts] input directly from cli after a function

2025-02-13 Thread Jabari Zakiya
Thanks! This works. func main() { var n int s := os.Args[1] n, err := strconv.Atoi(s) if err != nil {panic(err)} On Thursday, February 13, 2025 at 5:23:10 PM UTC-5 Ian Lance Taylor wrote: > On Thu, Feb 13, 2025 at 2:12 PM Jabari Zakiya wrote: > > > > I want to input an integer directl

Re: [go-nuts] input directly from cli after a function

2025-02-13 Thread Ian Lance Taylor
On Thu, Feb 13, 2025 at 2:12 PM Jabari Zakiya wrote: > > I want to input an integer directly after the function > > $ ./myfunction n (CR) > > not > > $ ./myfunction (CR) > n (CR) > > None of my search results explains how to do this. Sounds like you want to look at os.Args, which will contai

[go-nuts] input directly from cli after a function

2025-02-13 Thread Jabari Zakiya
I want to input an integer directly after the function $ ./myfunction n (CR) not $ ./myfunction (CR) n (CR) None of my search results explains how to do this. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group