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

support global config (e.g. for company-wide settings) #233

Merged
merged 2 commits into from
Sep 17, 2019
Merged

support global config (e.g. for company-wide settings) #233

merged 2 commits into from
Sep 17, 2019

Conversation

johnrichardrinehart
Copy link
Contributor

Addresses #232.

@mgechev
Copy link
Owner

mgechev commented Sep 16, 2019

Would you also document it in the README? Otherwise, LGTM!

@chavacava, would you take a look as well?

@chavacava chavacava requested review from mgechev and chavacava and removed request for mgechev September 16, 2019 07:35
config.go Outdated
excludeUsage = "list of globs which specify files to be excluded (i.e. -exclude foo/...)"
formatterUsage = "formatter to be used for the output (i.e. -formatter stylish)"
)
flag.StringVar(&configPath, "config", "", configUsage)

var globalConfigPath string
Copy link
Collaborator

Choose a reason for hiding this comment

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

I propose to rename globalConfigPath into defaultConfigPath.

To simplify the reading of the init() function we can also factor out the calculation of the default path into a helper function like

func buildDefaultConfigPath() string {
	var result string
	if homeDir, err := homedir.Dir(); err == nil {
		result = filepath.Join(homeDir, "revive.toml")
		if _, err := os.Stat(result); err != nil {
			result = ""
		}
	}

	return result
}

And just write

defaultConfigPath := buildDefaultConfigPath()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had similar sentiments. But, I didn't have a good idea about where to put the helper function.

Let me know what you think.

@chavacava Your changes have been implemented (logic moved to helper function).
@mgechev I have added documentation to the README. Thanks for reminding me.

@johnrichardrinehart
Copy link
Contributor Author

@mgechev I'm not sure how long you want to wait on @chavacava but I vote for closing #232 and merging #233.

@chavacava
Copy link
Collaborator

LGTM
(CI not working)

@mgechev mgechev merged commit 40564c5 into mgechev:master Sep 17, 2019
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.

3 participants