Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion godaemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func init() {
args := os.Args[1:]
i := 0
for ; i < len(args); i++ {
if args[i] == "-d=true" {
if args[i] == "-d" || args[i] == "-d=true" {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: The space-separated format -d true is also valid for Go boolean flags. When this format is used, the loop finds -d and converts it to -d=false, but leaves true as a dangling argument. Consider handling this case:

Suggested change
if args[i] == "-d" || args[i] == "-d=true" {
if args[i] == "-d" || args[i] == "-d=true" {
if args[i] == "-d" && i+1 < len(args) && args[i+1] == "true" {
args = append(args[:i+1], args[i+2:]...)
}
args[i] = "-d=false"
break
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: godaemon.go
Line: 20:20

Comment:
**style:** The space-separated format `-d true` is also valid for Go boolean flags. When this format is used, the loop finds `-d` and converts it to `-d=false`, but leaves `true` as a dangling argument. Consider handling this case:

```suggestion
			if args[i] == "-d" || args[i] == "-d=true" {
				if args[i] == "-d" && i+1 < len(args) && args[i+1] == "true" {
					args = append(args[:i+1], args[i+2:]...)
				}
				args[i] = "-d=false"
				break
			}
```

How can I resolve this? If you propose a fix, please make it concise.

args[i] = "-d=false"
break
}
Expand Down