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

linter warnings and autocompletion not working in a new go module project #250

Closed
scottjg opened this issue Jun 23, 2020 · 1 comment
Closed

Comments

@scottjg
Copy link

scottjg commented Jun 23, 2020

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go

    • go version go1.14.4 darwin/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders

    • 1.46.1
      cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
      x64
  • Check your installed extensions to get the version of the VS Code Go extension

    • 0.14.4
  • Run go env to get the go development environment details

% go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/scottjg/Library/Caches/go-build"
GOENV="/Users/scottjg/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/scottjg/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/scottjg/src/remote/server/go.mod"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/h_/0j5twwd916sb8d3vmhkdz8v40000gn/T/go-build860521658=/tmp/go-build -gno-record-gcc-switches -fno-common

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

{
  "go.formatTool": "goimports",
  "go.useLanguageServer": true
}

Describe the bug

A clear and concise description of what the bug.

autocompletion does not appear to be working and my import is being flagged as "could not import..."

Screen Shot 2020-06-23 at 12 44 18 PM

A clear and concise description of what you expected to happen.

no errors, working autocompletion

Steps to reproduce the behavior:

This was a fresh vscode install and a brand new go project.

scottjg@MacBook-Pro server % cat go.mod 
module github.com/rewatchtv/remote/server

go 1.14

require github.com/gorilla/websocket v1.4.2
scottjg@MacBook-Pro server % cat main.go
package main

import (
        "flag"

        "github.com/gorilla/websocket"
)

var addr = flag.String("addr", "localhost:8080", "http service address")

var upgrader = websocket.Upgrader{} // use default options

func main() {
}

after creating the project, and building it with go build (so dependencies are downloaded), i installed the go extension and chose to install all the tools when prompted by dialogs in vscode. I don't have a GOPATH set, but this is a go module project, so i don't think it's needed? these are all default vscode settings set by the Go extension.

@scottjg
Copy link
Author

scottjg commented Jun 23, 2020

nevermind... eventually a dialog popped up saying that for go module projects to work, you have to open an editor window with the go.mod file at the root. weird that it didn't appear until i started randomly changing preferences, but it seems to be working.

@scottjg scottjg closed this as completed Jun 23, 2020
@golang golang locked and limited conversation to collaborators Jun 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants