I have two go files in a directory.
Go
├── mains.go
└── vars.go
The code for the mains.go and vars.go are given below:
mains.go
--------
package main
import "fmt"
func main() {
fmt.Println("This is the mains file")
}
vars.go
--------
package main
import "fmt"
func main() {
fmt.Println("This is the vars file")
}
While running the file individually using the terminal command
go run mains.go
go run vars.go
I am getting the output. When I am using VScode, I am getting the following error
main redeclared in this block
previous declaration at ./mains.go:5:6
Due to this error, I am not able to run the code. The code runs fine when each file is separated into folders. I tried to remove the main declaration from the file before saving but the autocomplete/autoformat feature fills the package main & import "fmt" commands automatically. My doubts are :
Is this the problem with the editor? (As the terminal commands run fine)
Any other recommended IDE for go?
My specs
Ubuntu : 16.04
Visual Studio Code : 1.23.1
go version : 1.9.2