joefitzgerald / go-plus

An Enhanced Go Experience For The Atom Editor
https://atom.io/packages/go-plus
Other
1.51k stars 128 forks source link

Trouble compiling on save with go-plus and atom, not in terminal #792

Closed chezearth closed 5 years ago

chezearth commented 6 years ago

Prerequisites

Description

Saving a .go file with go-plus installed causes the following error in the output when it tries to compile:

can't load package: package go: no Go files in /usr/local/go/src/go
can't load package: package build: cannot find package "build" in any of:
    /usr/local/go/src/build (from $GOROOT)
    /Users/Charles/Code/go-workspace/src/build (from $GOPATH)

Doing an ls on the two paths in the error text above gives:

$ ls /usr/local/go/src/go/
./        ../       ast/      build/    constant/ doc/      format/   importer/ internal/ parser/   printer/  scanner/  token/    types/
$ ls /usr/local/go/src/build/
ls: /usr/local/go/src/build: No such file or directory

the first directory has no go files, only directories ; and the second does not exist. How are these two directories set in go-plus?

Output from atom -v && apm -v

Atom    : 1.28.2
Electron: 2.0.5
Chrome  : 61.0.3163.100
Node    : 8.9.3
apm  1.19.0
npm  3.10.10
node 6.9.5 x64
atom 1.28.2
python 2.7.10
git 2.18.0

Output From go env

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/Charles/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/Charles/Code/go-workspace"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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/tg/sbf0zmz96n343tmjmfrqql6h0000gn/T/go-build766853227=/tmp/go-build -gno-record-gcc-switches -fno-common"
14_functions/07_variadic-params/main.go3:8
LFUTF-8Go
masterFetch1 file

also

$ go version
go version go1.10.3 darwin/amd64

My $GOPATH, i.e., /Users/Charles/Code/go-workspace has the usual bin, 'pkg and src directories in it.

Steps to Reproduce

Make a small Go file in the editor and save it (ctrl-s) to get go-plus to build (install). In the terminal, using go build . or go install . in the file's directory causes no problems.

I was previously trying to install a syntax highlighter that works (go-plus doesn't seem to do this) and I tried a few other packages when this problem started. I have since deinstalled all packages from Atom associated with GoLang or any other language, leaving only a few decorative packages such as file-icons. May this have somehow affected the package's paths (my $GOPATH, $GOROOT haven't changed)?

Expected Behavior

The file should be compiled.

Actual Behavior

This error is produced in the Output pane of go-plus:

can't load package: package go: no Go files in /usr/local/go/src/go
can't load package: package build: cannot find package "build" in any of:
    /usr/local/go/src/build (from $GOROOT)
    /Users/Charles/Code/go-workspace/src/build (from $GOPATH)
zmb3 commented 6 years ago

Hi there! Happy to help figure out what's going on.

What does the sample Go file that you're trying to compile look like? And what's the location of the file on disk? Is it in your $GOPATH?

I wouldn't expect other Atom packages to affect the paths that go-plus uses. Note though that syntax highlighting for Go is provided by language-go, which is bundled with Atom. You shouldn't have to install anything extra to get syntax highlighting.

chezearth commented 6 years ago

Thanks for the help. My sample Go file:

package main

import "fmt"

func main() {
    fmt.Println(greet("Jane", "Doe"))
}

func greet(fname, lname string) (string, string) {
    return fmt.Sprint(fname, lname), fmt.Sprint(lname, fname)
}

Really simple. Yes, the file is in a subdirectory of my $GOPATH. language-go is installed but there is no highlighting (which I presume means syntax errors are highlighted, usually by red underlining?).

zmb3 commented 6 years ago

Nothing stands out as obviously wrong so far.

chezearth commented 6 years ago

Dear Zac,

The issues page won’t allow me to send any more comments. Anyway, here is my file’s path, my $GOPATH variable and the response to $ which go.

file at /Users/Charles/Code/go-workspace/src/github.com/chezearth/udemyGolangTraining/14_functions/07_variadic-params/main.go

$ echo $GOPATH 
/Users/Charles/Code/go-workspace

$ which go
/usr/local/go/bin/go

On 17 Jul 2018, at 23:25, Zac Bergquist notifications@github.com wrote:

Hi there! Happy to help figure out what's going on.

What does the sample Go file that you're trying to compile look like? And what's the location of the file on disk? Is it in your $GOPATH?

I wouldn't expect other Atom packages to affect the paths that go-plus uses. Note though that syntax highlighting for Go is provided by language-go, which is bundled with Atom. You shouldn't have to install anything extra to get syntax highlighting.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/joefitzgerald/go-plus/issues/792#issuecomment-405733303, or mute the thread https://github.com/notifications/unsubscribe-auth/AFB01WaRNatRl6h5M2NzL4OYUEoYb6_fks5uHlZhgaJpZM4VThjQ.

chezearth commented 6 years ago

I installed from the GoLang website (not from HomeBrew). Upgraded from 1.5 to 1.10 after the problem started.

On 17 Jul 2018, at 23:41, Zac Bergquist notifications@github.com wrote:

Nothing stands out as obviously wrong so far.

What's the exact path of the Go file? What is the output of which go? How did you install Go? Could it be that you have more than one version installed? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/joefitzgerald/go-plus/issues/792#issuecomment-405737489, or mute the thread https://github.com/notifications/unsubscribe-auth/AFB01a2fJTU9gMkZECN5lyeT9tkV5J9Tks5uHloWgaJpZM4VThjQ.

zmb3 commented 6 years ago

Thanks for the details. Everything seems ok so far. Have you tried launching Atom from a terminal inside the project directory?

Users/Charles/Code/go-workspace/src/github.com/chezearth/udemyGolangTraining/14_functions/07_variadic-params/$ atom .

It might help to try to clear out your $GOPATH/pkg directory in case any old Go 1.5 libraries are still sitting in there.

Does this happen on any Go code you try to write, or just this particular project?

That's all the ideas I have for now. If you're up for it, we may be able to do a screen share to take a closer look at what's going on.

chezearth commented 6 years ago

Tried launching Atom from the a terminal inside the directory. Same result. Cleared out the pkg/ directory ... same result afterwards. It happens on all my go files. I'm ok to try a screen share. Tomorrow? My time is 00:19 GMT +2. Now it's really late my side.

chezearth commented 6 years ago

Ok, I seem to have got somewhere. I downgraded my version to 5.6.0 using apm install go-plus@5.6.0 and yes, it's fixed! Atom then asked me to upgrade, of course, which I did, and hey, presto, the issue's back. Seems to be a version thing. I'll try and figure out which is latest working version.

chezearth commented 6 years ago

Just to add to my last comment: versions up to 5.7.2 work fine. From 5.8.1 onwards, the issue is there.

zmb3 commented 6 years ago

I'm GMT +1 this weekend - if you want to try to set up a time, please join the Atom slack and send me a DM (link below).

Slack

zmb3 commented 5 years ago

Going to close this as there hasn't been any activity in a while. Feel free to open a new issue if you need more help.

chezearth commented 5 years ago

Dear Zac,

Thank you for this information.

I did experience a problem with a previous version of go-plus (it was current in June-July 2018) and I had to downgrade to an even older version to avoid it. However, I have now upgraded again to the latest versions (current in December 2018) and go-plus is working beautifully. So yes, happy you closed.

Charles Rethman

19 Sans Souci Road, Newlands, 7700 rethman@telkomsa.net rethman@me.com skype: cwrethman mobile: +27 71 6735502 home: +27 21 6861510

On 21 Jan 2019, at 18:44, Zac Bergquist notifications@github.com wrote:

Closed #792 https://github.com/joefitzgerald/go-plus/issues/792.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/joefitzgerald/go-plus/issues/792#event-2086879215, or mute the thread https://github.com/notifications/unsubscribe-auth/AFB01TrOnWgaezLO4hoS3a9LHISlmi6sks5vFe5egaJpZM4VThjQ.