在go语言中,import导入的时候导入的是路径,而在使用的时候使用的是package名
例如:
test.go:
package t_unit
//import "fmt"
type Sort interface {
Min(a int) bool
}
//func init() {
// fmt.Println("aaassadas")
//}
root.go:
package main
import (
"fmt"
//导入的是路径(相对与src)
"aaa/unit"
)
type Integer struct {
a int
}
func (a Integer) Min(b int) bool {
return a.a < b;
}
//使用的是package名(t_unit)
func test(s t_unit.Sort) {
fmt.Println(s.Min(20))
}
func main() {
var b Integer
test(b)
}