文件:$ GOPATH / src / scratch_go_code / main / main.go
package main
import "fmt"
func main() {
fmt.Println("Hello World")
cloud := Cloud{}
cloud.Say()
}
文件$ GOPATH / src / scratch_go_code / main / cloud.go
package main
import "fmt"
type Cloud struct{}
func (Cloud) Say() {
fmt.Println("I'm a cloud in the main package")
}
运行:转到安装scratch_go_code / ... &&转到运行main / main.go引发:
# command-line-arguments
main/main.go:7: undefined: Cloud
知道为什么吗?
这应该工作
go build scratch_go_code/main
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句