Cant import my packages


(Andrew) #1

Hi i cant import my packages.
I have Project “Education”, there one of directories- “7_package”, there src(main.go)->user(user.go)
in user.go I have variable Username. When i want to call that value from main.go as user.Username, its importing “os/user”, not “user”, and when i delete “os/”, it says "Build constraints exclude all Go files in ‘C:/Go/src/user’ ", but my project path is C:/user/prog/goworkspace/[here all my projects]
I am using GoLand IDE

upd. Created mypack->src->friend, in src - main.go(fmt.Println(friend.Username), in friend - friend.go (var Username = “Tom”). now i cant even try to import that package


(Илья Бельтюков) #2

If the entire file is at the same level of nesting with the one into which you are trying to import, you do not need to register the import. Just refer to the variable Username = "some" in main file.


(Илья Бельтюков) #3

And if u use GoLand will be batter use IDE builder, 55
It’s in top right corner of the ide screen, edit build configuration, and specify build from directory


(Andrew) #4

no:




(Norbert Melzer) #5

Just using a random qualifier doesn’t help, you need to import a package first by its fully qualified name.

import "user" in your case if I’m reading the screenshots correctly.