Tag Archives: cannot find package “fmt” in any of

Go build Error: cannot find package “fmt” in any of [How to Solve]

0. The project codes are as follows: 

The project code is written in gopath/SRC/Demo1/main/main.go

The go build command is executed under the gopath directory

1. The screenshot of error report is as follows: 2

Error reason: the wrong configuration of the root is caused by the FMT package in the error message. It points to F:: (go/bin/SRC) FMT, which indicates that our root is configured as the F:: (go/bin) directory. By default, go goes to the root/SRC directory to find the package directly introduced in our code

2. The solution is to modify the root and change the root to F: 2

After modification, recompile it