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

x/tools/gopls: unable to import packages (GOPATH) #39560

Closed
lolbinarycat opened this issue Jun 12, 2020 · 26 comments
Closed

x/tools/gopls: unable to import packages (GOPATH) #39560

lolbinarycat opened this issue Jun 12, 2020 · 26 comments

Comments

@lolbinarycat
Copy link

@lolbinarycat lolbinarycat commented Jun 12, 2020

What did you do?

I was working on this program in spacemacs using lsp-mode with gopls

What did you expect to see?

there should be no errors with package imports, as the program compiles and runs

What did you see instead?

3 package errors for the lines with:
"github.com/oakmound/oak/collision"
"github.com/oakmound/oak/key"
"github.com/oakmound/oak/render"
each error in the form of "could not import PACKAGENAME (no package for import PACKAGENAME)

Build info

version master, built in $GOPATH mode

Go info

go version go1.14.1 linux/amd64

@gopherbot gopherbot added the Tools label Jun 12, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 12, 2020

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

@gopherbot gopherbot added the gopls label Jun 12, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jun 12, 2020
@lolbinarycat
Copy link
Author

@lolbinarycat lolbinarycat commented Jun 12, 2020

.spacemacs:

;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.

(defun dotspacemacs/layers ()
  "Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
  (setq-default
   ;; Base distribution to use. This is a layer contained in the directory
   ;; `+distribution'. For now available distributions are `spacemacs-base'
   ;; or `spacemacs'. (default 'spacemacs)
   dotspacemacs-distribution 'spacemacs
   ;; Lazy installation of layers (i.e. layers are installed only when a file
   ;; with a supported type is opened). Possible values are `all', `unused'
   ;; and `nil'. `unused' will lazy install only unused layers (i.e. layers
   ;; not listed in variable `dotspacemacs-configuration-layers'), `all' will
   ;; lazy install any layer that support lazy installation even the layers
   ;; listed in `dotspacemacs-configuration-layers'. `nil' disable the lazy
   ;; installation feature and you have to explicitly list a layer in the
   ;; variable `dotspacemacs-configuration-layers' to install it.
   ;; (default 'unused)
   dotspacemacs-enable-lazy-installation 'unused
   ;; If non-nil then Spacemacs will ask for confirmation before installing
   ;; a layer lazily. (default t)
   dotspacemacs-ask-for-lazy-installation t
   ;; If non-nil layers with lazy install support are lazy installed.
   ;; List of additional paths where to look for configuration layers.
   ;; Paths must have a trailing slash (i.e. `~/.mycontribs/')
   dotspacemacs-configuration-layer-path '()
   ;; List of configuration layers to load.
   dotspacemacs-configuration-layers
   '(
     python
     (go :variables go-tab-width 4 go-backend 'lsp)
     ;; ----------------------------------------------------------------
     ;; Example of useful layers you may want to use right away.
     ;; Uncomment some layer names and press <SPC f e R> (Vim style) or
     ;; <M-m f e R> (Emacs style) to install them.
     ;; ----------------------------------------------------------------
     helm
     auto-completion
     ;; better-defaults
     emacs-lisp
     ;; git
     ;; markdown
     ;;org
     ;; (shell :variables
     ;;        shell-default-height 30
     ;;        shell-default-position 'bottom)
     ;; spell-checking
     ;; syntax-checking
     ;; version-control

     lsp
     )
   ;; List of additional packages that will be installed without being
   ;; wrapped in a layer. If you need some configuration for these
   ;; packages, then consider creating a layer. You can also put the
   ;; configuration in `dotspacemacs/user-config'.
   dotspacemacs-additional-packages '((markdown-mode) (gdscript-mode :location local))
   ;; A list of packages that cannot be updated.
   dotspacemacs-frozen-packages '()
   ;; A list of packages that will not be installed and loaded.
   dotspacemacs-excluded-packages '(company-go)
   ;; Defines the behaviour of Spacemacs when installing packages.
   ;; Possible values are `used-only', `used-but-keep-unused' and `all'.
   ;; `used-only' installs only explicitly used packages and uninstall any
   ;; unused packages as well as their unused dependencies.
   ;; `used-but-keep-unused' installs only the used packages but won't uninstall
   ;; them if they become unused. `all' installs *all* packages supported by
   ;; Spacemacs and never uninstall them. (default is `used-only')
   dotspacemacs-install-packages 'used-only))

(defun dotspacemacs/init ()
  "Initialization function.
This function is called at the very startup of Spacemacs initialization
before layers configuration.
You should not put any user code in there besides modifying the variable
values."
  ;; This setq-default sexp is an exhaustive list of all the supported
  ;; spacemacs settings.
  (setq-default
   ;; If non nil ELPA repositories are contacted via HTTPS whenever it's
   ;; possible. Set it to nil if you have no way to use HTTPS in your
   ;; environment, otherwise it is strongly recommended to let it set to t.
   ;; This variable has no effect if Emacs is launched with the parameter
   ;; `--insecure' which forces the value of this variable to nil.
   ;; (default t)
   dotspacemacs-elpa-https t
   ;; Maximum allowed time in seconds to contact an ELPA repository.
   dotspacemacs-elpa-timeout 5
   ;; If non nil then spacemacs will check for updates at startup
   ;; when the current branch is not `develop'. Note that checking for
   ;; new versions works via git commands, thus it calls GitHub services
   ;; whenever you start Emacs. (default nil)
   dotspacemacs-check-for-update nil
   ;; If non-nil, a form that evaluates to a package directory. For example, to
   ;; use different package directories for different Emacs versions, set this
   ;; to `emacs-version'.
   dotspacemacs-elpa-subdirectory nil
   ;; One of `vim', `emacs' or `hybrid'.
   ;; `hybrid' is like `vim' except that `insert state' is replaced by the
   ;; `hybrid state' with `emacs' key bindings. The value can also be a list
   ;; with `:variables' keyword (similar to layers). Check the editing styles
   ;; section of the documentation for details on available variables.
   ;; (default 'vim)
   dotspacemacs-editing-style 'emacs
   ;; If non nil output loading progress in `*Messages*' buffer. (default nil)
   dotspacemacs-verbose-loading nil
   ;; Specify the startup banner. Default value is `official', it displays
   ;; the official spacemacs logo. An integer value is the index of text
   ;; banner, `random' chooses a random text banner in `core/banners'
   ;; directory. A string value must be a path to an image format supported
   ;; by your Emacs build.
   ;; If the value is nil then no banner is displayed. (default 'official)
   dotspacemacs-startup-banner 'official
   ;; List of items to show in startup buffer or an association list of
   ;; the form `(list-type . list-size)`. If nil then it is disabled.
   ;; Possible values for list-type are:
   ;; `recents' `bookmarks' `projects' `agenda' `todos'."
   ;; List sizes may be nil, in which case
   ;; `spacemacs-buffer-startup-lists-length' takes effect.
   dotspacemacs-startup-lists '((recents . 5)
                                (projects . 7))
   ;; True if the home buffer should respond to resize events.
   dotspacemacs-startup-buffer-responsive t
   ;; Default major mode of the scratch buffer (default `text-mode')
   dotspacemacs-scratch-mode 'text-mode
   ;; List of themes, the first of the list is loaded when spacemacs starts.
   ;; Press <SPC> T n to cycle to the next theme in the list (works great
   ;; with 2 themes variants, one dark and one light)
   dotspacemacs-themes '(spacemacs-dark
                         spacemacs-light)
   ;; If non nil the cursor color matches the state color in GUI Emacs.
   dotspacemacs-colorize-cursor-according-to-state t
   ;; Default font, or prioritized list of fonts. `powerline-scale' allows to
   ;; quickly tweak the mode-line size to make separators look not too crappy.
   pacemacs-default-font '("Source Code Pro"
                               :size 13
                               :weight normal
                               :width normal
                               :powerline-scale 1.1)
   ;; The leader key
   dotspacemacs-leader-key "SPC"
   ;; The key used for Emacs commands (M-x) (after pressing on the leader key).
   ;; (default "SPC")
   dotspacemacs-emacs-command-key "SPC"
   ;; The key used for Vim Ex commands (default ":")
   dotspacemacs-ex-command-key ":"
   ;; The leader key accessible in `emacs state' and `insert state'
   ;; (default "M-m")
   dotspacemacs-emacs-leader-key "M-m"
   ;; Major mode leader key is a shortcut key which is the equivalent of
   ;; pressing `<leader> m`. Set it to `nil` to disable it. (default ",")
   dotspacemacs-major-mode-leader-key ","
   ;; Major mode leader key accessible in `emacs state' and `insert state'.
   ;; (default "C-M-m")
   dotspacemacs-major-mode-emacs-leader-key "C-M-m"
   ;; These variables control whether separate commands are bound in the GUI to
   ;; the key pairs C-i, TAB and C-m, RET.
   ;; Setting it to a non-nil value, allows for separate commands under <C-i>
   ;; and TAB or <C-m> and RET.
   ;; In the terminal, these pairs are generally indistinguishable, so this only
   ;; works in the GUI. (default nil)
   dotspacemacs-distinguish-gui-tab nil
   ;; If non nil `Y' is remapped to `y$' in Evil states. (default nil)
   dotspacemacs-remap-Y-to-y$ nil
   ;; If non-nil, the shift mappings `<' and `>' retain visual state if used
   ;; there. (default t)
   dotspacemacs-retain-visual-state-on-shift t
   ;; If non-nil, J and K move lines up and down when in visual mode.
   ;; (default nil)
   dotspacemacs-visual-line-move-text nil
   ;; If non nil, inverse the meaning of `g' in `:substitute' Evil ex-command.
   ;; (default nil)
   dotspacemacs-ex-substitute-global nil
   ;; Name of the default layout (default "Default")
   dotspacemacs-default-layout-name "Default"
   ;; If non nil the default layout name is displayed in the mode-line.
   ;; (default nil)
   dotspacemacs-display-default-layout nil
   ;; If non nil then the last auto saved layouts are resume automatically upon
   ;; start. (default nil)
   dotspacemacs-auto-resume-layouts nil
   ;; Size (in MB) above which spacemacs will prompt to open the large file
   ;; literally to avoid performance issues. Opening a file literally means that
   ;; no major mode or minor modes are active. (default is 1)
   dotspacemacs-large-file-size 1
   ;; Location where to auto-save files. Possible values are `original' to
   ;; auto-save the file in-place, `cache' to auto-save the file to another
   ;; file stored in the cache directory and `nil' to disable auto-saving.
   ;; (default 'cache)
   dotspacemacs-auto-save-file-location 'cache
   ;; Maximum number of rollback slots to keep in the cache. (default 5)
   dotspacemacs-max-rollback-slots 5
   ;; If non nil, `helm' will try to minimize the space it uses. (default nil)
   dotspacemacs-helm-resize nil
   ;; if non nil, the helm header is hidden when there is only one source.
   ;; (default nil)
   dotspacemacs-helm-no-header nil
   ;; define the position to display `helm', options are `bottom', `top',
   ;; `left', or `right'. (default 'bottom)
   dotspacemacs-helm-position 'bottom
   ;; Controls fuzzy matching in helm. If set to `always', force fuzzy matching
   ;; in all non-asynchronous sources. If set to `source', preserve individual
   ;; source settings. Else, disable fuzzy matching in all sources.
   ;; (default 'always)
   dotspacemacs-helm-use-fuzzy 'always
   ;; If non nil the paste micro-state is enabled. When enabled pressing `p`
   ;; several times cycle between the kill ring content. (default nil)
   dotspacemacs-enable-paste-transient-state nil
   ;; Which-key delay in seconds. The which-key buffer is the popup listing
   ;; the commands bound to the current keystroke sequence. (default 0.4)
   dotspacemacs-which-key-delay 0.4
   ;; Which-key frame position. Possible values are `right', `bottom' and
   ;; `right-then-bottom'. right-then-bottom tries to display the frame to the
   ;; right; if there is insufficient space it displays it at the bottom.
   ;; (default 'bottom)
   dotspacemacs-which-key-position 'bottom
   ;; If non nil a progress bar is displayed when spacemacs is loading. This
   ;; may increase the boot time on some systems and emacs builds, set it to
   ;; nil to boost the loading time. (default t)
   dotspacemacs-loading-progress-bar t
   ;; If non nil the frame is fullscreen when Emacs starts up. (default nil)
   ;; (Emacs 24.4+ only)
   dotspacemacs-fullscreen-at-startup nil
   ;; If non nil `spacemacs/toggle-fullscreen' will not use native fullscreen.
   ;; Use to disable fullscreen animations in OSX. (default nil)
   dotspacemacs-fullscreen-use-non-native nil
   ;; If non nil the frame is maximized when Emacs starts up.
   ;; Takes effect only if `dotspacemacs-fullscreen-at-startup' is nil.
   ;; (default nil) (Emacs 24.4+ only)
   dotspacemacs-maximized-at-startup nil
   ;; A value from the range (0..100), in increasing opacity, which describes
   ;; the transparency level of a frame when it's active or selected.
   ;; Transparency can be toggled through `toggle-transparency'. (default 90)
   dotspacemacs-active-transparency 90
   ;; A value from the range (0..100), in increasing opacity, which describes
   ;; the transparency level of a frame when it's inactive or deselected.
   ;; Transparency can be toggled through `toggle-transparency'. (default 90)
   dotspacemacs-inactive-transparency 90
   ;; If non nil show the titles of transient states. (default t)
   dotspacemacs-show-transient-state-title t
   ;; If non nil show the color guide hint for transient state keys. (default t)
   dotspacemacs-show-transient-state-color-guide t
   ;; If non nil unicode symbols are displayed in the mode line. (default t)
   dotspacemacs-mode-line-unicode-symbols t
   ;; I had to add this in manualy to make the file work
   dotspacemacs-mode-line-theme 'spacemacs
   ;; If non nil smooth scrolling (native-scrolling) is enabled. Smooth
   ;; scrolling overrides the default behavior of Emacs which recenters point
   ;; when it reaches the top or bottom of the screen. (default t)
   dotspacemacs-smooth-scrolling t
   ;; Control line numbers activation.
   ;; If set to `t' or `relative' line numbers are turned on in all `prog-mode' and
   ;; `text-mode' derivatives. If set to `relative', line numbers are relative.
   ;; This variable can also be set to a property list for finer control:
   ;; '(:relative nil
   ;;   :disabled-for-modes dired-mode
   ;;                       doc-view-mode
   ;;                       markdown-mode
   ;;                       org-mode
   ;;                       pdf-view-mode
   ;;                       text-mode
   ;;   :size-limit-kb 1000)
   ;; (default nil)
   dotspacemacs-line-numbers nil
   ;; Code folding method. Possible values are `evil' and `origami'.
   ;; (default 'evil)
   dotspacemacs-folding-method 'evil
   ;; If non-nil smartparens-strict-mode will be enabled in programming modes.
   ;; (default nil)
   dotspacemacs-smartparens-strict-mode nil
   ;; If non-nil pressing the closing parenthesis `)' key in insert mode passes
   ;; over any automatically added closing parenthesis, bracket, quote, etc…
   ;; This can be temporary disabled by pressing `C-q' before `)'. (default nil)
   dotspacemacs-smart-closing-parenthesis nil
   ;; Select a scope to highlight delimiters. Possible values are `any',
   ;; `current', `all' or `nil'. Default is `all' (highlight any scope and
   ;; emphasis the current one). (default 'all)
   dotspacemacs-highlight-delimiters 'all
   ;; If non nil, advise quit functions to keep server open when quitting.
   ;; (default nil)
   dotspacemacs-persistent-server nil
   ;; List of search tool executable names. Spacemacs uses the first installed
   ;; tool of the list. Supported tools are `ag', `pt', `ack' and `grep'.
   ;; (default '("ag" "pt" "ack" "grep"))
   dotspacemacs-search-tools '("ag" "pt" "ack" "grep")
   ;; The default package repository used if no explicit repository has been
   ;; specified with an installed package.
   ;; Not used for now. (default nil)
   dotspacemacs-default-package-repository nil
   ;; Delete whitespace while saving buffer. Possible values are `all'
   ;; to aggressively delete empty line and long sequences of whitespace,
   ;; `trailing' to delete only the whitespace at end of lines, `changed'to
   ;; delete only whitespace for changed lines or `nil' to disable cleanup.
   ;; (default nil)
   dotspacemacs-whitespace-cleanup nil
   ))

(defun dotspacemacs/user-init ()
  "Initialization function for user code.
It is called immediately after `dotspacemacs/init', before layer configuration
executes.
 This function is mostly useful for variables that need to be set
before packages are loaded. If you are unsure, you should try in setting them in
`dotspacemacs/user-config' first."
  ;;  (setq-default tab-width 4)
  
  )

(defun dotspacemacs/user-config ()
  (require 'gdscript-mode)
  (setq-default tab-width 4)
  ;;(eval-after-load "company" '(add-to-list 'company-backend 'lsp))

  "Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration.
This is the place where most of your configurations should be done. Unless it is
explicitly specified that a variable should be set before a package is loaded,
you should place your code here."
  ;;(org-reload)
)

;; Do not write anything past this comment. This is where Emacs will
;; auto-generate custom variable definitions.
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(indent-tabs-mode t)
 '(package-selected-packages
   (quote
    (yapfify pyvenv pytest pyenv-mode py-isort pip-requirements live-py-mode hy-mode dash-functional helm-pydoc cython-mode company-anaconda anaconda-mode pythonic helm-company helm-c-yasnippet fuzzy company-statistics company-go company auto-yasnippet yasnippet ac-ispell auto-complete gdscript-mode go-guru go-eldoc go-mode ws-butler winum which-key volatile-highlights vi-tilde-fringe uuidgen use-package toc-org spaceline powerline restart-emacs request rainbow-delimiters popwin persp-mode pcre2el paradox spinner markdown-mode org-plus-contrib org-bullets open-junk-file neotree move-text macrostep lorem-ipsum linum-relative link-hint indent-guide hydra hungry-delete hl-todo highlight-parentheses highlight-numbers highlight-indentation helm-themes helm-swoop helm-projectile helm-mode-manager helm-make helm-flx helm-descbinds helm-ag google-translate golden-ratio flx-ido fill-column-indicator fancy-battery eyebrowse expand-region exec-path-from-shell evil-visualstar evil-visual-mark-mode evil-unimpaired evil-tutor evil-surround evil-search-highlight-persist evil-numbers evil-nerd-commenter evil-mc evil-matchit evil-lisp-state evil-indent-plus evil-iedit-state evil-exchange evil-escape evil-ediff evil-args evil-anzu eval-sexp-fu elisp-slime-nav dumb-jump diminish define-word column-enforce-mode clean-aindent-mode bind-key auto-highlight-symbol auto-compile aggressive-indent adaptive-wrap ace-window ace-link ace-jump-helm-line)))
 '(standard-indent 2))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
(defun dotspacemacs/emacs-custom-settings ()
  "Emacs custom settings.
This is an auto-generated function, do not modify its content directly, use
Emacs customize menu instead.
This function is called at the very end of Spacemacs initialization."
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(indent-tabs-mode t)
 '(package-selected-packages
   (quote
    (posframe dap-mode bui yapfify pyvenv pytest pyenv-mode py-isort pip-requirements live-py-mode hy-mode dash-functional helm-pydoc cython-mode company-anaconda anaconda-mode pythonic helm-company helm-c-yasnippet fuzzy company-statistics company auto-yasnippet yasnippet ac-ispell auto-complete gdscript-mode go-guru go-eldoc ws-butler winum which-key volatile-highlights vi-tilde-fringe uuidgen use-package toc-org spaceline powerline restart-emacs request rainbow-delimiters popwin persp-mode pcre2el paradox spinner markdown-mode org-plus-contrib org-bullets open-junk-file neotree move-text macrostep lorem-ipsum linum-relative link-hint indent-guide hydra hungry-delete hl-todo highlight-parentheses highlight-numbers highlight-indentation helm-themes helm-swoop helm-projectile helm-mode-manager helm-make helm-flx helm-descbinds helm-ag google-translate golden-ratio flx-ido fill-column-indicator fancy-battery eyebrowse expand-region exec-path-from-shell evil-visualstar evil-visual-mark-mode evil-unimpaired evil-tutor evil-surround evil-search-highlight-persist evil-numbers evil-nerd-commenter evil-mc evil-matchit evil-lisp-state evil-indent-plus evil-iedit-state evil-exchange evil-escape evil-ediff evil-args evil-anzu eval-sexp-fu elisp-slime-nav dumb-jump diminish define-word column-enforce-mode clean-aindent-mode bind-key auto-highlight-symbol auto-compile aggressive-indent adaptive-wrap ace-window ace-link ace-jump-helm-line)))
 '(standard-indent 2))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
)
@heschik
Copy link
Contributor

@heschik heschik commented Jun 12, 2020

Please follow the troubleshooting guide linked above. In particular, make sure your program compiles with "go build" and attach logs.

@lolbinarycat
Copy link
Author

@lolbinarycat lolbinarycat commented Jun 12, 2020

Please follow the troubleshooting guide linked above. In particular, make sure your program compiles with "go build" and attach logs.

Well, I dosen't compile now specifically, because I'm in the middle of overhauling it, but it did when I was having the issue.

As for logs, I don't know how I would do that, and it sounds like it would be kind of a pain. There's about 3 layers between me and gopls, so It seems quite hard.

As for the troubleshooting guide, yes, I tried both of the 2 suggestions, and they didn't work.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jun 12, 2020

Based on the gopls version you reported above, I wonder if you have an outdated version. Please try reinstalling it by running GO111MODULE=on go get golang.org/x/tools/gopls@lastest.

@lolbinarycat
Copy link
Author

@lolbinarycat lolbinarycat commented Jun 12, 2020

@stamblerre
You were right, I wasn't on the latest version, now I am, and it's worse!
Now instead of 3 import errors, I get 6!

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jun 12, 2020

A common issue is that you must open your workspace root to a directory that is at the root or a subdirectory of your module (the directory containing the go.mod). In Emacs, I believe their are commands to achieve this - you can see more in the Emacs docs.

You can also run gopls -rpc.trace -v check path/to/file.go and see if that produces similar errors. If it does, you can share these logs here and we can help.

@stamblerre stamblerre changed the title x/tools/gopls: Gopls dosn't recognize certain packages when imported x/tools/gopls: doesn't recognize certain packages when imported Jun 12, 2020
@stamblerre stamblerre changed the title x/tools/gopls: doesn't recognize certain packages when imported x/tools/gopls: doesn't recognize imported packages Jun 12, 2020
@lolbinarycat
Copy link
Author

@lolbinarycat lolbinarycat commented Jun 13, 2020

the module problem sounds like a likely cause, unfortunately I don't understand much about it. the only go.mod file relating to my current project is the one for the game engine/library I am using, which is somewhere in my GOPATH are you suggesting I set my workspace root there? It is nowhere near the files I am working on, which seems counter to the idea of a "workspace root", but I don't really know much about this stuff.

I ran the suggested command, and I got similar errors (but different to both other sets of errors) different errors every time I ran the command.
Here is the output of one of the commands:

2020/06/13 09:45:38 Info:2020/06/13 09:45:38 Build info
----------
golang.org/x/tools/gopls 0.4.1
    golang.org/x/tools/gopls@v0.4.1 h1:0e3BPxGV4B3cd0zdMuccwW72SgmHp92lAjOyxX/ScAw=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
    golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
    golang.org/x/tools@v0.0.0-20200513154647-78b527d18275 h1:e7nYe9s94RHunFJ7b+mmPxiQMOKMVSqYASToWb1EcHs=
    golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
    honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=
    mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=

Go info
-------
go version go1.14.1 linux/amd64


2020/06/13 09:45:39 Info:2020/06/13 09:45:39 go/packages.Load
        snapshot=0
        directory=/home/binarycat
        query=[./ builtin]
        packages=2
2020/06/13 09:45:39 Info:2020/06/13 09:45:39 go env for /home/binarycat
(valid build configuration = false)
(build flags: [])
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/binarycat/.cache/go-build"
GOENV="/home/binarycat/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/binarycat/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build290664203=/tmp/go-build -gno-record-gcc-switches"

2020/06/13 09:45:39 Info:2020/06/13 09:45:39 go/packages.Load
        snapshot=0
        directory=/home/binarycat
        query=[./]
        packages=1
2020/06/13 09:45:39 Info:2020/06/13 09:45:39 go/packages.Load
        snapshot=1
        directory=/home/binarycat
        query=[./]
        packages=1
2020/06/13 09:45:40 Info:2020/06/13 09:45:40 go/packages.Load
        snapshot=1
        directory=/home/binarycat
        query=[file=/home/binarycat/Programs/hookshot-oak/main.go]
        packages=1
2020/06/13 09:45:40 Info:2020/06/13 09:45:40 go/packages.Load
        snapshot=1
        package_path="command-line-arguments"
        files=[/home/binarycat/Programs/hookshot-oak/main.go]
/home/binarycat/Programs/hookshot-oak/main.go:9:2-37: could not import github.com/oakmound/oak/collision (no package for import github.com/oakmound/oak/collision)
/home/binarycat/Programs/hookshot-oak/main.go:11:2-33: could not import github.com/oakmound/oak/event (no package for import github.com/oakmound/oak/event)
/home/binarycat/Programs/hookshot-oak/main.go:12:2-31: could not import github.com/oakmound/oak/key (no package for import github.com/oakmound/oak/key)
/home/binarycat/Programs/hookshot-oak/main.go:13:2-35: could not import github.com/oakmound/oak/physics (no package for import github.com/oakmound/oak/physics)
/home/binarycat/Programs/hookshot-oak/main.go:14:2-34: could not import github.com/oakmound/oak/render (no package for import github.com/oakmound/oak/render)
/home/binarycat/Programs/hookshot-oak/main.go:15:2-33: could not import github.com/oakmound/oak/scene (no package for import github.com/oakmound/oak/scene)
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jun 14, 2020

Thanks for the clarification and the logs. It sounds like your intention is to use GOPATH, not modules. In that case, you do not have to set your workspace root.

However, it looks like your project is not in your GOPATH. Your GOPATH is /home/binarycat/go, but your project is in /home/binarycat/Programs/hookshot-oak/. To import dependencies from your GOPATH, you will need to put your project in a subdirectory of /home/binarycat/go/src. (More details can be found here).

@lolbinarycat
Copy link
Author

@lolbinarycat lolbinarycat commented Jun 14, 2020

@stamblerre huh, so apparently I've been programming go wrong the whole time. surprised the compiler didn't complain about it, with how picky it is. Guess that's what I get for skimming tutorials.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jun 14, 2020

You can avoid putting your code in GOPATH by using Go modules. The compiler was probably able to find your dependencies in your GOPATH, but gopls doesn't load your entire workspace if it detects an invalid build configuration.

Since it seems that we've uncovered the problem, can this issue be closed?

@lolbinarycat
Copy link
Author

@lolbinarycat lolbinarycat commented Jun 14, 2020

Sadly, even after moving my project into GOPATH, I still get several errors for package imports.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jun 15, 2020

Please provide the updated output of gopls -rpc.trace -v check path/to/file.go.

@lolbinarycat
Copy link
Author

@lolbinarycat lolbinarycat commented Jun 15, 2020

2020/06/15 10:32:42 Info:2020/06/15 10:32:42 Build info
----------
golang.org/x/tools/gopls 0.4.1
    golang.org/x/tools/gopls@v0.4.1 h1:0e3BPxGV4B3cd0zdMuccwW72SgmHp92lAjOyxX/ScAw=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
    golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
    golang.org/x/tools@v0.0.0-20200513154647-78b527d18275 h1:e7nYe9s94RHunFJ7b+mmPxiQMOKMVSqYASToWb1EcHs=
    golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
    honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=
    mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=

Go info
-------
go version go1.14.1 linux/amd64


2020/06/15 10:32:43 Info:2020/06/15 10:32:43 go/packages.Load
        snapshot=0
        directory=/home/binarycat
        query=[./ builtin]
        packages=2
2020/06/15 10:32:43 Info:2020/06/15 10:32:43 go env for /home/binarycat
(valid build configuration = false)
(build flags: [])
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/binarycat/.cache/go-build"
GOENV="/home/binarycat/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/binarycat/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build866027543=/tmp/go-build -gno-record-gcc-switches"

2020/06/15 10:32:43 Info:2020/06/15 10:32:43 go/packages.Load
        snapshot=0
        directory=/home/binarycat
        query=[./]
        packages=1
2020/06/15 10:32:43 Info:2020/06/15 10:32:43 go/packages.Load
        snapshot=1
        directory=/home/binarycat
        query=[./]
        packages=1
2020/06/15 10:32:44 Info:2020/06/15 10:32:44 go/packages.Load
        snapshot=1
        package_path="custom/hookshot-oak"
        files=[/home/binarycat/go/src/custom/hookshot-oak/editor.go /home/binarycat/go/src/custom/hookshot-oak/main.go]
2020/06/15 10:32:44 Info:2020/06/15 10:32:44 go/packages.Load
        snapshot=1
        directory=/home/binarycat
        query=[file=/home/binarycat/go/src/custom/hookshot-oak/main.go]
        packages=1
/home/binarycat/go/src/custom/hookshot-oak/main.go:10:2-37: could not import github.com/oakmound/oak/collision (no package for import github.com/oakmound/oak/collision)
/home/binarycat/go/src/custom/hookshot-oak/main.go:12:2-33: could not import github.com/oakmound/oak/event (no package for import github.com/oakmound/oak/event)
/home/binarycat/go/src/custom/hookshot-oak/main.go:300:6-10: main redeclared in this block
/home/binarycat/go/src/custom/hookshot-oak/main.go:209:17-23: mov.GetPos undefined (type *entities.Moving has no field or method GetPos)
/home/binarycat/go/src/custom/hookshot-oak/main.go:211:33-34: mov.Y undefined (type *entities.Moving has no field or method Y)
/home/binarycat/go/src/custom/hookshot-oak/main.go:219:28-34: object.Body.GetPos undefined (type *entities.Moving has no field or method GetPos)
/home/binarycat/go/src/custom/hookshot-oak/main.go:228:16-20: object.Body.SetX undefined (type *entities.Moving has no field or method SetX)
/home/binarycat/go/src/custom/hookshot-oak/main.go:233:16-20: object.Body.SetX undefined (type *entities.Moving has no field or method SetX)
/home/binarycat/go/src/custom/hookshot-oak/main.go:246:16-20: object.Body.SetY undefined (type *entities.Moving has no field or method SetY)
/home/binarycat/go/src/custom/hookshot-oak/main.go:249:16-20: object.Body.SetY undefined (type *entities.Moving has no field or method SetY)

(many of these errors are cascading errors due to the library that a function is in not being imported).

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jun 15, 2020

@lolbinarycat: It looks like gopls is still not recognizing your setup as a valid configuration. What directory are you running the command from? Make sure to run it from within the /home/binarycat/go/src/custom/ directory.

@lolbinarycat
Copy link
Author

@lolbinarycat lolbinarycat commented Jun 15, 2020

Tried that, still getting errors.

Is there a timeout option or something somewhere? It's very strange that the errors are different every time, even with the same file.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jun 15, 2020

Is it possible that the errors are ordered differently but are still the same?
If you can continue sharing the output that would be helpful. Another thing to try is running go list -e -json ./... in the /home/binarycat/go/src/custom/ directory, as that is what gopls runs under the hood.

@lolbinarycat
Copy link
Author

@lolbinarycat lolbinarycat commented Jun 15, 2020

For go list -e -json ...:

{
        "Dir": "/home/binarycat/go/src/custom/hookshot-oak",
        "ImportPath": "command-line-arguments",
        "Name": "main",
        "Root": "/home/binarycat/go",
        "Match": [
                "./hookshot-oak/main.go"
        ],
        "Stale": true,
        "StaleReason": "stale dependency: github.com/oakmound/oak/collision",
        "GoFiles": [
                "main.go"
        ],
        "Imports": [
                "fmt",
                "github.com/oakmound/oak",
                "github.com/oakmound/oak/collision",
                "github.com/oakmound/oak/entities",
                "github.com/oakmound/oak/event",
                "github.com/oakmound/oak/key",
                "github.com/oakmound/oak/physics",
                "github.com/oakmound/oak/render",
                "github.com/oakmound/oak/scene",
                "image/color",
                "os",
                "time"
        ],
        "Deps": [
                "bufio",
                "bytes",
                "compress/flate",
                "compress/lzw",
                "compress/zlib",
                "container/heap",
                "context",
                "encoding",
                "encoding/base64",
                "encoding/binary",
                "encoding/hex",
                "encoding/json",
                "errors",
                "fmt",
                "github.com/200sc/go-dist/colorrange",
                "github.com/200sc/go-dist/intrange",
                "github.com/200sc/klangsynthese/audio",
                "github.com/200sc/klangsynthese/audio/filter",
                "github.com/200sc/klangsynthese/audio/filter/supports",
                "github.com/200sc/klangsynthese/audio/manip",
                "github.com/200sc/klangsynthese/font",
                "github.com/200sc/klangsynthese/mp3",
                "github.com/200sc/klangsynthese/wav",
                "github.com/BurntSushi/toml",
                "github.com/BurntSushi/xgb",
                "github.com/BurntSushi/xgb/render",
                "github.com/BurntSushi/xgb/shape",
  "github.com/BurntSushi/xgb/shm",
                "github.com/BurntSushi/xgb/xinerama",
                "github.com/BurntSushi/xgb/xproto",
                "github.com/BurntSushi/xgbutil",
                "github.com/BurntSushi/xgbutil/ewmh",
                "github.com/BurntSushi/xgbutil/motif",
                "github.com/BurntSushi/xgbutil/xevent",
                "github.com/BurntSushi/xgbutil/xprop",
                "github.com/akavel/polyclip-go",
                "github.com/davecgh/go-spew/spew",
                "github.com/disintegration/gift",
                "github.com/golang/freetype/raster",
                "github.com/golang/freetype/truetype",
                "github.com/hajimehoshi/go-mp3",
                "github.com/hajimehoshi/go-mp3/internal/bits",
                "github.com/hajimehoshi/go-mp3/internal/consts",
                "github.com/hajimehoshi/go-mp3/internal/frame",
                "github.com/hajimehoshi/go-mp3/internal/frameheader",
                "github.com/hajimehoshi/go-mp3/internal/huffman",
                "github.com/hajimehoshi/go-mp3/internal/imdct",
                "github.com/hajimehoshi/go-mp3/internal/maindata",
                "github.com/hajimehoshi/go-mp3/internal/sideinfo",
                "github.com/oakmound/libudev",
                "github.com/oakmound/libudev/types",
                "github.com/oakmound/oak",
                "github.com/oakmound/oak/alg",
                "github.com/oakmound/oak/alg/floatgeom",
                "github.com/oakmound/oak/alg/intgeom",
                "github.com/oakmound/oak/audio",
                "github.com/oakmound/oak/collision",
                "github.com/oakmound/oak/dlog",
                "github.com/oakmound/oak/entities",
                "github.com/oakmound/oak/event",
                "github.com/oakmound/oak/fileutil",
                "github.com/oakmound/oak/joystick",
                "github.com/oakmound/oak/key",
                "github.com/oakmound/oak/mouse",
                "github.com/oakmound/oak/oakerr",
                "github.com/oakmound/oak/physics",
                "github.com/oakmound/oak/render",
                "github.com/oakmound/oak/render/mod",
                "github.com/oakmound/oak/scene",
                "github.com/oakmound/oak/shape",
                "github.com/oakmound/oak/timing",
                "github.com/oakmound/shiny/driver",
                "github.com/oakmound/shiny/driver/internal/drawer",
                "github.com/oakmound/shiny/driver/internal/errscreen",
                "github.com/oakmound/shiny/driver/internal/event",
                "github.com/oakmound/shiny/driver/internal/lifecycler",
                "github.com/oakmound/shiny/driver/internal/swizzle",
                "github.com/oakmound/shiny/driver/internal/x11",
                "github.com/oakmound/shiny/driver/internal/x11key",
                "github.com/oakmound/shiny/driver/x11driver",
                "github.com/oakmound/shiny/gesture",
                "github.com/oakmound/shiny/screen",
                "github.com/pkg/errors",
                "github.com/yobert/alsa",
                "github.com/yobert/alsa/alsatype",
                "github.com/yobert/alsa/color",
                "github.com/yobert/alsa/pcm",
                "github.com/yobert/alsa/pcm/state",
                "golang.org/x/image/bmp",
                "golang.org/x/image/colornames",
                "golang.org/x/image/font",
                "golang.org/x/image/math/f64",
                "golang.org/x/image/math/fixed",
                "golang.org/x/mobile/event/key",
                "golang.org/x/mobile/event/lifecycle",
                "golang.org/x/mobile/event/mouse",
                "golang.org/x/mobile/event/paint",
                "golang.org/x/mobile/event/size",
                "golang.org/x/mobile/geom",
                "golang.org/x/sync/syncmap",
                "hash",
                "hash/adler32",
                "hash/crc32",
                "image",
                "image/color",
                "image/color/palette",
                "image/draw",
                "image/gif",
                "image/internal/imageutil",
                "image/jpeg",
                "image/png",
                "internal/bytealg",
                "internal/cpu",
                "internal/fmtsort",
                "internal/nettrace",
                "internal/oserror",
                "internal/poll",
                "internal/race",
                "internal/reflectlite",
                "internal/singleflight",
                "internal/syscall/unix",
                "internal/testlog",
                "io",
                "io/ioutil",
                "log",
                "math",
                "math/bits",
                "math/rand",
                "net",
                "os",
                "path",
                "path/filepath",
                "reflect",
                "regexp",
                "regexp/syntax",
                "runtime",
                "runtime/cgo",
                "runtime/internal/atomic",
                "runtime/internal/math",
                "runtime/internal/sys",
                "sort",
                "strconv",
                "strings",
                "sync",
                "sync/atomic",
                "syscall",
                "time",
                "unicode",
                "unicode/utf16",
                "unicode/utf8",
                "unsafe",
                "vendor/golang.org/x/net/dns/dnsmessage"
        ]
}

No, the errors are not the same. The reason I stopped sharing the output is that due to several unrelated issues, they are quite cumbersome to copy paste, and running the command twice while changing nothing generates two different outputs.

This means that for any given thing I try, there is a practically unlimited number of outputs I could get. And the command does not run quickly on my computer.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jun 15, 2020

I really cannot help you resolve this issue without the output of those commands. My best guess is that your GOPATH remains somewhat misconfigured, and gopls is not able to find your imports. If you do check your gopls logs or try to run this command again, you're looking for (valid build configuration = true) to appear in the logs. My recommendation is also to open the root of your project directory in your editor.

@lolbinarycat
Copy link
Author

@lolbinarycat lolbinarycat commented Jun 15, 2020

If it was just GOPATH being misconfigured, I would expect the errors to be the same every time.
and if that's not enough, I ran the command again, and what do you know! valid build config and still errors.

2020/06/15 13:49:51 Info:2020/06/15 13:49:51 Build info
----------
golang.org/x/tools/gopls 0.4.1
    golang.org/x/tools/gopls@v0.4.1 h1:0e3BPxGV4B3cd0zdMuccwW72SgmHp92lAjOyxX/ScAw=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
    golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
    golang.org/x/tools@v0.0.0-20200513154647-78b527d18275 h1:e7nYe9s94RHunFJ7b+mmPxiQMOKMVSqYASToWb1EcHs=
    golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
    honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=
    mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=

Go info
-------
go version go1.14.1 linux/amd64


2020/06/15 13:49:53 Info:2020/06/15 13:49:53 go env for /home/binarycat/go/src/custom
(valid build configuration = true)
(build flags: [])
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/binarycat/.cache/go-build"
GOENV="/home/binarycat/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/binarycat/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build040304964=/tmp/go-build -gno-record-gcc-switches"

2020/06/15 13:50:20 Info:2020/06/15 13:50:20 go/packages.Load
        snapshot=0
        directory=/home/binarycat/go/src/custom
        query=[./... builtin]
        packages=7
/home/binarycat/go/src/custom/hookshot-oak/main.go:10:2-37: could not import github.com/oakmound/oak/collision (no package for import github.com/oakmound/oak/collision)
/home/binarycat/go/src/custom/hookshot-oak/main.go:12:2-33: could not import github.com/oakmound/oak/event (no package for import github.com/oakmound/oak/event)
/home/binarycat/go/src/custom/hookshot-oak/main.go:13:2-31: could not import github.com/oakmound/oak/key (no package for import github.com/oakmound/oak/key)
/home/binarycat/go/src/custom/hookshot-oak/main.go:14:2-35: could not import github.com/oakmound/oak/physics (no package for import github.com/oakmound/oak/physics)
/home/binarycat/go/src/custom/hookshot-oak/main.go:15:2-34: could not import github.com/oakmound/oak/render (no package for import github.com/oakmound/oak/render)
/home/binarycat/go/src/custom/hookshot-oak/main.go:16:2-33: could not import github.com/oakmound/oak/scene (no package for import github.com/oakmound/oak/scene)
/home/binarycat/go/src/custom/hookshot-oak/main.go:302:6-10: main redeclared in this block
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jun 15, 2020

Well that is certainly an improvement.
To confirm, all of the github.com/oakmound/oak/ packages are also on your GOPATH (in the /home/binarycat/go/src/ folder)?

It also looks like there may be an issue in your code:

/home/binarycat/go/src/custom/hookshot-oak/main.go:302:6-10: main redeclared in this block

seems like a legitimate error, indicating you have multiple func main in your code.
If you're willing to share the content of the main.go file, that may help clarify what's going on.

@lolbinarycat
Copy link
Author

@lolbinarycat lolbinarycat commented Jun 16, 2020

@stamblerre Yes, all the packages are in GOPATH. The code is avalible here.

While there is only one main function in main.go, editor.go (a file that I was going to do something with but never got around to it), also starts with package main and has func main in it. Would that cause that error, and if so, what is the best way to handle it?

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jun 16, 2020

Thank you for sharing the link to the source code - I'm able to reproduce this issue. I'll spend some time debugging to understand what's going on.

@stamblerre stamblerre changed the title x/tools/gopls: doesn't recognize imported packages x/tools/gopls: unable to import packages (GOPATH) Jun 16, 2020
@heschik
Copy link
Contributor

@heschik heschik commented Jun 16, 2020

I haven't fully investigated this, but the issue is almost certainly related to minimal module compatibility, as documented on the modules wiki. The true import path of "github.com/oakmound/oak/event" is "github.com/oakmound/oak/v2/event". The former works in GOPATH mode only.

I'll see if there's a quick fix, but I'd suggest switching to module mode by running go mod init in the project directory.

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 16, 2020

Change https://golang.org/cl/238260 mentions this issue: internal/lsp/cache: support minimal module compatibility in GOPATH

@lolbinarycat
Copy link
Author

@lolbinarycat lolbinarycat commented Jun 20, 2020

switching to module mode seems to have fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.