Skip to content

Conversation

haridutt12
Copy link
Owner

…package


func main() {

minusS := flag.Bool("s", false, "Sockets")
Copy link
Collaborator

Choose a reason for hiding this comment

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

why minusS? what does that mean?

Copy link
Collaborator

Choose a reason for hiding this comment

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

similarly for all the other flags

flags := flag.Args()

printAll := false
if *minusS && *minusP && *minusSL && *minusD && *minusF {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is making the logic complex, why not create a list of all and then check for each flag and remove values one by one

printAll = true
}

if !(*minusS || *minusP || *minusSL || *minusD || *minusF) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you follow above comment, this will not be needed

printAll = true
}

if len(flags) == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why check for len? if you have to treat flags as positional arguments then wh use flag package at all? then you can use os.ARGS only

Copy link
Owner Author

Choose a reason for hiding this comment

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

since we are using flag for flags anyways and it has abstration over os.Args which does the same job

Copy link
Collaborator

Choose a reason for hiding this comment

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

You mean using flag you can get positional as well as names arguments at the same time?

Copy link
Owner Author

Choose a reason for hiding this comment

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

yes using flag.Args we can take positional arguments only difference between this and os.Args is its indexing starts from zero

}

fileInfo, _ = os.Lstat(path)
if fileInfo.Mode()&os.ModeSymlink != 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

there are formatting issues, please use goImports on save in sublime. Google it how to do that

Copy link
Owner Author

Choose a reason for hiding this comment

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

added goimport on save in sublime


fileInfo, _ = os.Lstat(path)
if fileInfo.Mode()&os.ModeSymlink != 0 {
if *minusSL {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please rename flag names so that I can understand what are they for.

}
}

if fileInfo.Mode()&os.ModeNamedPipe != 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add comments above each such check and explain what are you trying to do

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants