6
如何“运行”主程序包中包含多个文件的项目?
我目前在主包中只有一个文件,名为main.go。如何分割内容main.go由于代码不可重用,为多个文件而不创建单独的程序包。 我想要这样的目录结构: $ ls foo main.go bar.go bar.go package main import "fmt" func Bar() { fmt.Println("Bar") } 然后在 main.go package main func main() { Bar() } 但是go run main.go给我: # command-line-arguments ./main.go:4:2: undefined: Bar
150
go