我的代码:
package sort_test
type SortList []interface{}
type SortFunc func(interface{}, interface{}) bool
func Do(list SortList, function SortFunc)
主包
package main
import (
"sort_test"
)
func main() {
list := []int{3, 4, 5, 6, 6, 77, 4, 4, 5, 6, 8, 345, 45, 424, 2, 67, 7, 830}
slice := list[:]
sort_test.Do(slice, function)
}
编译错误
src/algorithm/algorithm.go:32: cannot use slice (type []int) as type sort_test.SortList in argument to sort_test.Do
src/algorithm/algorithm.go:32: cannot use function (type func(int, int) bool) as type sort_test.SortFunc in argument to sort_test.Do
make: *** [algorithm] Error 2
缥缈止盈
Helenr
相关分类