Error compiling GoLand

Hi, i have a problem with compiling code, where code isnt in 1 file .go

Studying go by one resource service, there was a topic about "imports and packages". I repeated that code and have error.

I created project, created there directory "somecode" and there i have 2 files: factorial.go and main.go, both of files have package main for sure.

and i am getting this error:

But if I move factorial.go in new package - it works -_-

THE SECOND PROBLEM - i cant use imports by myself, when i do import "fmt" it just disappears, imports works only when i do some code and it appears by itself

0
5 comments
Official comment

Hi.

> and i am getting this error:

This is because factorial.go is not compiled. If you want to compile several files you should select both of them and run via right click menu. Or run entire directory/package via right click menu. Or edit manually run configuration to tell GoLand what exactly files you want to compile (menu Run | Edit configurations).

> THE SECOND PROBLEM - i cant use imports by myself, when i do import "fmt" it just disappears, imports works only when i do some code and it appears by itself

We've made some changes in it in GoLand 2019.1, so auto-removing will be less aggressive for users who like add imports manually. Now you can disable auto-removing unused imports via `Preferences | Go | Imports | Optimize imports on the fly`.

thank you!

but why people always tell no full PATH? ZZzzzz.

Triggering that so much) how to find "Preferences"?)

0

It depends on OS. For mac it's just Preferences. For other OS it's `File | Settings`. Also, you can find any action using Ctrl+Shift+A (Cmd+A on mac) shortcut or using Shift+Shift shortcut.

0

and how can i see GOPATH? 

i have problem, when i have mypackage(main.go)->src->user(user.go), i want to import user to main.go, but it importing "os/user", not "user" as it needed

0

Please sign in to leave a comment.