标签:ima fun func 并且 exp test http 否则 pack
如果要用 gopath模式 引入包 从src目录下开始引入 需要关闭 go mod 模式
export GO111MODULE=off
如果使用go mod 模式
export GO111MODULE=on
并且在目录下执行 go mod init
否则就会报错
package wang/test is not in GOROOT (/usr/local/go/src/wang/test)

main.go
package main
import (
	"wang/test"
	"wang/test/yong"
)
func main()  {
	test.Say()
	yong.Speak()
}
test.go
package test
import "fmt"
func Say()  {
	fmt.Println("i am test")
}
yong.go
package yong
import "fmt"
func Speak()  {
	fmt.Println("i am speak")
}
package wang/test is not in GOROOT (/usr/local/go/src/wang/test)
标签:ima fun func 并且 exp test http 否则 pack
原文地址:https://www.cnblogs.com/php-linux/p/13069053.html