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
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
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
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