我正在使用 golang 和 GoLand(Jetbrains)IDE 在 UBUNTU 上进行开发。我的 Go 路径是/usr/local/go
,我的项目目录位于目录/Home/GoLandProjects
和bin, src, pkg
我的项目目录中。
去版本 go1.16.7 linux/amd64
我的 GOPATH 在 .bashrc 中是这样设置的:
export GOPATH="$HOME/GolandProjects"
export PATH="$PATH:$GOPATH/bin:/usr/local/go/bin"
一切都很好,如果我运行我的代码,它完全可以正常工作,但我的导入会出现问题,没有显示智能建议。从项目内部导入不起作用。
import (
"context" //woking
"errors" //woking
"go.mongodb.org/mongo-driver/bson" //woking
"go.mongodb.org/mongo-driver/bson/primitive" //woking
"go.mongodb.org/mongo-driver/mongo" //woking
"my-server/helpers" //not woking - not showing intelliSense and in Red Color
"my-server/models" //not woking - not showing intelliSense and in Red Color
"time" //woking
)
代码正在运行,但没有内部导入的智能感知。
我的 go.mod 文件:
module my-server
// +heroku goVersion go1.16
go 1.16
require (
cloud.google.com/go v0.91.1 // indirect
cloud.google.com/go/firestore v1.5.0 // indirect
cloud.google.com/go/storage v1.16.0 // indirect
firebase.google.com/go v3.13.0+incompatible
github.com/aead/chacha20poly1305 v0.0.0-20170617001512-233f39982aeb // indirect
github.com/gin-contrib/cors v1.3.1
github.com/gin-gonic/gin v1.7.3
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/mikunalpha/goas v1.6.0 // indirect
github.com/o1egl/paseto v1.0.0
go.mongodb.org/mongo-driver v1.7.1
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d // indirect
golang.org/x/oauth2 v0.0.0-20210810183815-faf39c7919d5
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/api v0.54.0
google.golang.org/genproto v0.0.0-20210813162853-db860fec028c // indirect
google.golang.org/grpc v1.40.0 // indirect
)
ls -alR
drwxrwxr-x 9 zainkhan zainkhan 4096 Sep 4 12:40 .
drwxrwxr-x 8 zainkhan zainkhan 4096 Sep 2 16:45 ..
-rw-rw-r-- 1 zainkhan zainkhan 2373 Sep 2 16:42 admin-pk.json
drwxrwxr-x 2 zainkhan zainkhan 4096 Sep 4 17:08 controllers
-rw-rw-r-- 1 zainkhan zainkhan 2383 Sep 2 16:42 credentials.json
-rw-rw-r-- 1 zainkhan zainkhan 123 Sep 2 16:42 Dockerfile
drwxrwxr-x 8 zainkhan zainkhan 4096 Sep 4 17:08 .git
drwxrwxr-x 3 zainkhan zainkhan 4096 Sep 2 16:42 .github
-rw-rw-r-- 1 zainkhan zainkhan 6 Sep 2 16:42 .gitignore
-rw-rw-r-- 1 zainkhan zainkhan 1078 Sep 4 12:40 go.mod
-rw-rw-r-- 1 zainkhan zainkhan 70236 Sep 2 16:45 go.sum
drwxrwxr-x 2 zainkhan zainkhan 4096 Sep 3 12:45 helpers
drwxrwxr-x 3 zainkhan zainkhan 4096 Sep 4 17:14 .idea
-rw-rw-r-- 1 zainkhan zainkhan 1403 Sep 4 12:40 main.go
drwxrwxr-x 3 zainkhan zainkhan 4096 Sep 4 16:28 models
drwxrwxr-x 2 zainkhan zainkhan 4096 Sep 4 17:08 services
在助手目录中
./helpers:
total 20
drwxrwxr-x 2 zainkhan zainkhan 4096 Sep 3 12:45 .
drwxrwxr-x 9 zainkhan zainkhan 4096 Sep 4 12:40 ..
-rw-rw-r-- 1 zainkhan zainkhan 16 Sep 2 16:42 firebase.go
-rw-rw-r-- 1 zainkhan zainkhan 854 Sep 2 16:42 mongo.go
-rw-rw-r-- 1 zainkhan zainkhan 3138 Sep 3 12:45 mongo_utils.go