autocomplete-go
autocomplete-go copied to clipboard
No suggestions are made, type signatures are still shown.
Prerequisites
- [x] Have you run
go get -u github.com/nsf/gocode
(emphasis on the-u
flag)? - [x] Have you tried launching
atom .
from the terminal in your project's directory? - [x] Have you verified the output from
go env
is correct? If it is, please include the output in this issue.
GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/leo/development/projects/go" GORACE="" GOROOT="/usr/lib/go" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build498199209=/tmp/go-build -gno-record-gcc-switches" CXX="g++" CGO_ENABLED="1"
- [x] Are you running the latest version of Atom? Have you tried Atom Beta, which can be run side-by-side with Atom Stable?
Atom 1.9.9
- [x] Have you updated your Atom packages?
- [x] Have you run
gocode
in server debug mode? In your terminal:- Run
gocode close
- Run
gocode -s -debug
- Type in atom
- Please include some debug output from gocode
- Run
2016/08/30 17:01:15 =======================================================
2016/08/30 17:01:16 Go project path: bitbucket.org/mr-zen/tzapi/routes
2016/08/30 17:01:16 Got autocompletion request for '/home/leo/development/projects/go/src/bitbucket.org/mr-zen/tzapi/routes/ugc.go'
2016/08/30 17:01:16 Cursor at: 603
2016/08/30 17:01:16 -------------------------------------------------------
package routes
import (
"net/http"
"strconv"
"bitbucket.org/mr-zen/tzapi/db"
"github.com/gorilla/mux"
)
// UGCRouter is the RESTful resource
type UGCRouter struct{}
// Route given a subrouter will setup routes for the resource
func (u UGCRouter) Route(r *mux.Router) {
r.HandleFunc("/stats", u.Stats).Methods(http.MethodGet)
}
// Stats gets the statisics for review scores from UGC
func (u UGCRouter) Stats(w http.ResponseWriter, r *http.Request) {
var ugc []db.UGCItem
var count uint64
var totalScore uint64
query := db.UGCItem{State: 1}
scoreBuckets := make(map[uint64]uint64)
r.URL#()
// Get the global stats.
db.GetConnection().Select("id, metadata").Where(query).Find(&ugc)
for _, i := range ugc {
if i.Meta["rating"] != nil {
rating, err := strconv.ParseUint(i.Meta["rating"].(string), 10, 64)
if err == nil && rating > 0 {
count++
totalScore += rating
}
scoreBuckets[rating]++
}
}
avgScore := float64(totalScore) / float64(count)
respondJSON(w, map[string]interface{}{
"count": count,
"total_score": totalScore,
"avg_score": avgScore,
"score_buckets": scoreBuckets,
}, http.StatusOK)
return
}
2016/08/30 17:01:16 -------------------------------------------------------
2016/08/30 17:01:16 Found "net/http" at "/usr/lib/go/pkg/linux_amd64/net/http.a"
2016/08/30 17:01:16 Found "strconv" at "/usr/lib/go/pkg/linux_amd64/strconv.a"
2016/08/30 17:01:16 Found "bitbucket.org/mr-zen/tzapi/db" at "/home/leo/development/projects/go/pkg/linux_amd64/bitbucket.org/mr-zen/tzapi/db.a"
2016/08/30 17:01:16 Found "github.com/gorilla/mux" at "/home/leo/development/projects/go/pkg/linux_amd64/github.com/gorilla/mux.a"
2016/08/30 17:01:16 Error parsing input file (inner block):
2016/08/30 17:01:16 12:9: expected operand, found ')'
2016/08/30 17:01:16 17:2: expected ')', found 'for'
2016/08/30 17:01:16 17:6: expected ';', found 'IDENT' _
2016/08/30 17:01:16 29:2: expected declaration, found 'IDENT' avgScore
2016/08/30 17:01:16 extracted expression tokens: r
2016/08/30 17:01:16 Offset: 3
2016/08/30 17:01:16 Number of candidates found: 1
2016/08/30 17:01:16 Candidates are:
2016/08/30 17:01:16 var URL *url.URL
2016/08/30 17:01:16 =======================================================
Description
No completion suggestions are shown by autocomplete-go, although some information about type signatures is shown
Output From go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/leo/development/projects/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build498199209=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
Steps to Reproduce
- Have a function with a parameter which is an
*http.Request
- Start typing U
Expected Behavior
An *http.Request
should suggest URL
which in turns suggests Query
Actual Behavior
No suggestions are made.
Can you please try gocode close && gocode drop-cache && go get -u github.com/nsf/gocode
?
I've tried your suggestion but I'm still getting the same behaviour, the output from the gocode daemon is the same too, but just in case I'm wrong here it is:
tzapi|master⚡ ⇒ gocode -s -debug
2016/09/01 16:19:17 Go project path: bitbucket.org/mr-zen/tzapi/routes
2016/09/01 16:19:17 Got autocompletion request for '/home/leo/development/projects/go/src/bitbucket.org/mr-zen/tzapi/routes/ugc.go'
2016/09/01 16:19:17 Cursor at: 1727
2016/09/01 16:19:17 -------------------------------------------------------
package routes
import (
"errors"
"net/http"
"strconv"
"bitbucket.org/mr-zen/tzapi/db"
"github.com/gorilla/mux"
)
// UGCRouter is the RESTful resource
type UGCRouter struct{}
type ugcRatingStats struct {
Count uint64 `json:"count"`
TotalScore uint64 `json:"total_score"`
AvgScore float64 `json:"avg_score"`
ScoreBuckets map[uint64]uint64 `json:"score_buckets"`
}
// Route given a subrouter will setup routes for the resource
func (u UGCRouter) Route(r *mux.Router) {
r.HandleFunc("/stats", u.Stats).Methods(http.MethodGet)
}
// Stats gets the statisics for review scores from UGC
func (u UGCRouter) Stats(w http.ResponseWriter, r *http.Request) {
var ugc []db.UGCItem
query := db.UGCItem{State: 1}
params := r.URL.Query()
if extension := params.Get("extension"); extension != "" {
// If a filter is provided, use it to filter the UGC aggregated
extensionID := params.Get("id")
idQuery := map[string]interface{}{
"extension": extension,
"extension_id": extensionID,
}
var ids []uint
db.GetConnection().
Table(db.UGCItemUsage{}.TableName()).
Where(idQuery).
Pluck("item_id", &ids)
db.GetConnection().Select("id, metadata").
Where("state = ? AND id IN (?)", 1, ids).Find(&ugc)
if len(ugc) == 0 {
sendError(w, http.StatusNotFound, errors.New("No Matching UGC Found"))
return
}
} else {
// Get the global stats.
db.GetConnection().Select("id, metadata").Where(query).Find(&ugc)
}
respondJSON(w, getUGCRatingStats(ugc), http.StatusOK)
return
}
//
// Get the rating stats for a given.
func getUGCRatingStats(items []db.UGCItem) ugcRatingStats {
var count uint64
var totalScore uint64
scoreBuckets := make#(map[uint64]uint64)
for _, i := range items {
if i.Meta["rating"] != nil {
rating, err := strconv.ParseUint(i.Meta["rating"].(string), 10, 64)
if err == nil && rating > 0 {
count++
totalScore += rating
}
scoreBuckets[rating]++
}
}
avgScore := float64(totalScore) / float64(count)
return ugcRatingStats{
Count: count,
TotalScore: totalScore,
ScoreBuckets: scoreBuckets,
AvgScore: avgScore,
}
}
I've also tried gocode close && go install . && gocode drop-cache
to see if that has any effect.
Try which -a gocode
to see if you have multiple copies of gocode in your path
.
If that doesn't work, are you open to a screen sharing session to figure this out? If so, please join the #go-plus
channel in one of these Slack teams, and then direct message me your email address:
each of your code snippets contain syntax errors:
scoreBuckets := make(map[uint64]uint64)
r.URL#() // <------------------------
// Get the global stats.
var totalScore uint64
scoreBuckets := make#(map[uint64]uint64) // <------------------------
for _, i := range items {
maybe that's the reason why gocode
is complaining...
Those hashes aren't in the actual source code, I'm guessing that gocode adds them as markers, certainly the first is about where my cursor was...
On 1 Sep 2016 8:37 p.m., "Lukas Beranek" [email protected] wrote:
each of your code snippets contains syntax errors:
scoreBuckets := make(map[uint64]uint64)
r.URL#() // <------------------------ // Get the global stats.
var totalScore uint64 scoreBuckets := make#(map[uint64]uint64) // <------------------------ for _, i := range items {
maybe that's the reason why gocode is complaining...
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/joefitzgerald/autocomplete-go/issues/49#issuecomment-244188314, or mute the thread https://github.com/notifications/unsubscribe-auth/AAgteMenNT-BAKt09S_2y_4UunfiT_oxks5qlyl-gaJpZM4Jwslr .
I'm having similar problems. In my case the suggestions from gocode are not the ones displayed. I test this with a test function typing t.r inside the function. gocode suggests the correct Run function. autocomplete-go displays : rd, review and Run(). It seems as if autocomplete-go is ignoring gocode and displays the autocomplete-plus suggestions. Playing around with the "Suppress the Provider Built in ..." flag didn't change anything. The behaviour stays the same wether its on or off.
This is the code: func Test(t *testing.T) { t.r }
which -a gocode
- do you have multiple gocode binaries in your path?
$ which -a gocode /home/tinu/go/bin/gocode /home/tinu/go/bin/gocode $
I did all your suggestions incl. dropping the cache and of course getting the newest gocode. Also only 1 gocode is running.
BTW I have this problem on an Arch Linux system and on my docker image teenooch/go-atom
Are you open to a screen sharing session to figure this out? If so, please join the #go-plus
channel in one of these Slack teams, and then direct message me your email address:
FYI, I had that issue, or at least the same symptom and running gocode close && gocode drop-cache && go get -u github.com/nsf/gocode
fixed it for me. Thanks for that (and the plugin(s)) 😀
I had this issue because I had gocode set package-lookup-mode gb
when I was writing with http://getgb.io. I fixed it by running gocode set package-lookup-mode go
@LeoAdamek what is the output of gocode set
in terminal?
Lol, my auto-complete started working after I ran gocode -s -debug
.
:+1: Tried all the troubleshooting steps and was able to get the completion working by the gocode -s -debug
method.
Having dealt with broken auto-completion for a while now after trying everything else I found, gocode close && gocode drop-cache && go get -u github.com/nsf/gocode
finally did the trick for me. I recommend putting this into the FAQ.