-
Notifications
You must be signed in to change notification settings - Fork 670
Pull forward the declaration of the RouterConfig in main() #554
Conversation
flag.StringVar(&httpAddr, "httpaddr", fmt.Sprintf(":%d", weave.HTTPPort), "address to bind HTTP interface to (disabled if blank, absolute path indicates unix domain socket)") | ||
flag.IntVar(&config.ConnLimit, "connlimit", 30, "connection limit (0 for unlimited)") | ||
flag.IntVar(&config.BufSz, "bufsz", 8, "capture buffer size in MB") | ||
flag.StringVar(&httpAddr, "httpaddr", fmt.Sprintf(":%d", weave.HTTPPort), "address to bind HTTP interface to (disabled if blank, , absolute path indicates unix domain socket)") |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This eliminates a few variables, and the naming awkardness where we have corresponding but distinct flag and router config variables.
Comma gone again. (I notice that this page currently shows "rade commented on an outdated diff", confirming my suspicion that github can sometimes track PR comments across rebases.) |
The treatment of Overall I find this change makes the code less regular and makes it harder to figure out what the router config contains, since it gets created bit by bit. Is that outweighed by the 11 lines saved? |
Go is rather far from having such a type system.
The elimination of mess such as name vs ourName and password vs pwSlice is worth it on its own. And 11 lines is 11 lines. |
Right, but my point stands. There is a bad smell to setting a field value to something that is invalid and then mutating it to be valid.
I don't actually consider that to be messy. |
Reintroduced with a clearer name. |
Cheers. As for the overall change. I am still not convinced. Perhaps ask for a 3rd opinion? |
@bboreham, will you arbitrate? |
I like this change. Considering the way that |
Pull forward the declaration of the RouterConfig in main()
I did think about this, and as you mention the wrinkle is Name andNickName. I anticipated resistance to moving them out of RouterConfig to separate NewRouter parameters on the basis that it would revealing implementation details. It would be really nice if we could introduce a RouterCommon that had the common parts of Router and RouterConfig, and make it an anonymous field of both. But this uglifies the corresponding struct literals, because anonymous fields are not magical there. |
This eliminates a few variables, and the naming awkardness where we
have corresponding but distinct flag and router config variables.