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

fix invalid error message "no go files to analyze" #1154

Merged
merged 1 commit into from May 19, 2020

Conversation

jirfag
Copy link
Member

@jirfag jirfag commented May 18, 2020

In case of timeouts of go/packages loading
we could return such error.

Relates: #825

// Currently, go/packages doesn't guarantee that error will be returned
// if context was cancelled. See
// https://github.com/golang/tools/commit/c5cec6710e927457c3c29d6c156415e8539a5111#r39261855
if ctx.Err() != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps:

if err := ctx.Err(); err != nil {

would do? It would allow to avoid calling ctx.Err() twice.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't see any profit to save nanoseconds here :)

Copy link
Member Author

@jirfag jirfag May 19, 2020

Choose a reason for hiding this comment

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

update: maybe microseconds

func (c *cancelCtx) Err() error {
	c.mu.Lock()
	err := c.err
	c.mu.Unlock()
	return err
}

It doesn't make sense to waste time on such micro-optimization, there are a lot of things to save seconds of time

pkg/lint/load.go Outdated
// if context was cancelled. See
// https://github.com/golang/tools/commit/c5cec6710e927457c3c29d6c156415e8539a5111#r39261855
if ctx.Err() != nil {
return nil, errors.Wrap(ctx.Err(), "timeouted to load packages")
Copy link
Member

Choose a reason for hiding this comment

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

timeout is misspelled

Copy link
Member Author

Choose a reason for hiding this comment

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

thank you, fixed

In case of timeouts of go/packages loading
we could return such error.

Relates: #825
@jirfag jirfag force-pushed the feature/fix-no-go-files-to-analyze-on-timeout branch from aa8137f to d5f7501 Compare May 19, 2020 06:48
@jirfag jirfag merged commit 3c46e16 into master May 19, 2020
@delete-merged-branch delete-merged-branch bot deleted the feature/fix-no-go-files-to-analyze-on-timeout branch May 19, 2020 06:55
@ldez ldez added this to the v1.28 milestone Mar 6, 2024
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.

None yet

4 participants