Home > other >  The import import packages run error.
The import import packages run error.

Time:10-27

# go env | grep GOPATH
GOPATH="/home/hiller/gocode"

# CD/home/hiller gocode/SRC/test2

# cat test. Go
Package the main

Import (
"FMT"
"Test2
")

Func main () {
FMT. Println (" Hello, World!" )
Test2 ()
}


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

# cat test2. Go
Package test2

The import "FMT"

Func test2 () {
FMT. Println (" Hello, hiller!" )
}

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

# go run the test. Go
The test. Go: 5-2: found packages main (test. Go) and test2 (test2. Go) in/home/hiller/gocode/SRC/test2



Bosses, please help to look at, thank you,


CodePudding user response:

The test2. Go into SRC/test2 folder
Simply understanding, the package is on behalf of the folder, in addition to the main package, go source files should be put into the corresponding package folder,
  • Related