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

goflymake wrongly marking func main() as error #16

Open
indradhanush opened this issue Oct 17, 2014 · 5 comments
Open

goflymake wrongly marking func main() as error #16

indradhanush opened this issue Oct 17, 2014 · 5 comments

Comments

@indradhanush
Copy link

In all of my golang buffers, goflymake is marking my func main {} as an error although go run for that particular file works pretty well.

Here's a screenshot of the problem:
screen shot 2014-10-18 at 12 42 14 am

Also, my emacs configuration for go is pretty simple:

;; go-mode
(require 'go-mode-load)
(require 'go-flymake)
(require 'go-autocomplete)
(add-hook 'before-save-hook 'gofmt-before-save)
(add-hook 'go-mode-hook (lambda () (local-set-key (kbd "C-c C-r") 'go-remove-unused-imports)))
(add-hook 'go-mode-hook (lambda () (local-set-key (kbd "C-c i") 'go-goto-imports)))
(add-hook 'go-mode-hook (lambda () (local-set-key (kbd "C-c C-f") 'gofmt)))
(add-hook 'go-mode-hook (lambda () (local-set-key (kbd "C-c C-k") 'godoc)))

Also, unlike other actual errors, mouse hover displays information about the respective error, whereas in this case there is no such information.

Am I missing something?

@dominikh
Copy link

Are these files all in the same directory? In that case, that isn't a valid package, as you'd have multiple conflicting definitions of main.

@indradhanush
Copy link
Author

@dominikh, Yup they are, Hmm, how do I arrange those files then?

@dominikh
Copy link

A single directory holds a single package. If you want to have a project with many executables, a common structure is something like /cmd/progA/*.go, /cmd/progB/*.go.

See for example https://code.google.com/p/go/source/browse/?repo=tools#hg%2Fcmd -- the go.tools repository, which contains a number of utilities.

@abhat
Copy link

abhat commented Jul 21, 2015

+1. I am having a similar problem. In my case, main.go is the only file in my package directory and is also the only file that has a main function. Mouse-hover results in goflymake showing a tool-tip saying "main re-declared in this block".

@abhat
Copy link

abhat commented Jul 22, 2015

A little bit of experimentation and it seems like, if the file is named main.go or has the same name as the pkg directory name for instance if I have a path like: src/github.com/abhat/test_me and I have main() defined in a file called src/github.com/abhat/test_me.go or in a file called src/github.com/abhat/main.go, then goflymake will complain. Are these naming conventions frowned upon by golang?

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