有个学生管理系统
假设GPATH目录是
D:\Project\go\
有两个应用包 D:\Project\go\src\student\profile.go 学生属性
package student
func Say() string{
return "I am student profile"
}
D:\Project\go\src\teacher\profile.go 教师属性
package teacher
func Say() string {
return "I am teacher profile"
}
学生管理系统应用程序入口包是
D:\Project\go\src\manage\main.go
package main
import (
"fmt"
"lib/student"
"lib/teacher"
)
func main(){
fmt.Println("Hello student manage system")
fmt.Println(student.Say())
fmt.Println(teacher.Say())
}
Say 方法必须是开头字母大写,应为go规定开头字母大写才是public属性 可以外部调用
D:\Project\go\src\manage\ 目录下执行 go run ./main.go
D:\Project\go\src\manage> go run .\main.go
Hello student manage system
I am student profile
I am teacher profile
PS D:\Project\go\src\manage>