Skip to content

flag/flag.go panic: runtime error: index out of range [0] with length 0 #68340

@develerltd

Description

@develerltd

panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
flag.init()
/usr/local/go/src/flag/flag.go:1199 +0xfc

var CommandLine = NewFlagSet(os.Args[0], ExitOnError)

len(os.Args) > 1 is not always true, at least in Linux and macOS. If you compile a go program and then write a C program to exec it with execl("/path/to/exec", NULL), it will have no arguments at all, not even the executable name

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixPendingIssues that have a fix which has not yet been reviewed or submitted.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions