lib1/lib1.go
package lib1
import "fmt"
//当前lib1包提供的API
func Lib1Test() {
fmt.Println("lib1Test()...")
}
func init() {
fmt.Println("lib1. init() ...")
}
lib2/lib2.go
package lib2
import "fmt"
//当前lib2包提供的API
func Lib2Test() {
fmt.Println("lib2Test()...")
}
func init() {
fmt.Println("lib2. init() ...")
}
main.go
package main
import (
_ "GolangStudy/5-init/lib1"
mylib2 "GolangStudy/5-init/lib2"
//. "GolangStudy/5-init/lib2"
)
func main() {
//lib1.lib1Test()
//lib2.Lib2Test()
mylib2.Lib2Test()
//Lib2Test()
}