Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init() limits GOMAXPROCS and flags #16

Open
tpjg opened this issue Jun 26, 2012 · 2 comments
Open

init() limits GOMAXPROCS and flags #16

tpjg opened this issue Jun 26, 2012 · 2 comments

Comments

@tpjg
Copy link

tpjg commented Jun 26, 2012

Maybe it's just me, but it seems that calling flag.Parse() in redis.go/init() is causing my other flags to get ignored, maybe because this package loads before the "main" package? (I'm new to Go, so could be my mistake - and of course you can't be sure that any main package will actually call flag.Parse()).

Also, why is init() calling runtime.GOMAXPROCS(2) ?

@alphazero
Copy link
Owner

The flag parsing should be something you can test. (Haven't looked at it yet myself).
Hardcoded 2 is wrong - it should get cpu count from system.

@onewland
Copy link

flag.Parse is eating my app's command-line arguments. I've figured out a way to patch redis.go to fail but not bring flag's parsing operation with it, but there's no simple way in the 'flag' package to move past errors silently, so flags other than redis:d still cause an error message. It does at least suppress the usage message flag would normally print.

failf on http://golang.org/src/pkg/flag/flag.go line 643 shows how that parse error message gets generated, and there's no way to overwrite that handler without a patch to the main go language.

https://gist.github.com/3201682 is my updated init() for redis.go. It works because it doesn't try to use the default command line FlagSet and propagate the failure forward to the user's application. The overwrite of Usage is for error message suppression. I can put it in patch format if you want to add this in.

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

No branches or pull requests

3 participants