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

Unable to configure GoImports linter #939

Open
gz-c opened this issue Jul 24, 2019 · 1 comment
Open

Unable to configure GoImports linter #939

gz-c opened this issue Jul 24, 2019 · 1 comment

Comments

@gz-c
Copy link

gz-c commented Jul 24, 2019

There is no way to pass argument to the goimports linter. Previously this could be done with something like:

"fmt_cmd": ["goimports", "-srcdir", "$_dir", "-local", "github.com/gz-c/foo"],

Now it seems that the Args are buried inside here: https://github.com/KurokuLabs/margo/blob/45053645555797217b3f6df7d90975cbfae7e609/golang/gofmt.go#L47

In my case I use the -local flag to sort the imports differently. It would need to be configured per-package.

@DisposaBoy
Copy link
Owner

You can just create your own reducer to do fmt'ing:

	mg.NewReducer(func(mx *mg.Ctx) *mg.State {
		return mgformat.FmtCmd{
			Name:  "goimports",
			Args:  []string{"-srcdir", mx.View.Filename()},
			Langs: []mg.Lang{mg.Go},
			Actions: []mg.Action{
				mg.ViewFmt{},
				mg.ViewPreSave{},
			},
		}.Reduce(mx)
	}),

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

2 participants