首先,我们来看一个例子 type Stringer interface { String() string } type String struct { data string } func (s *String) String() string { return s.data } 上面是类型,然后 func GetString() *String { return nil } func CheckString(s Stringer) bool { return s == nil } func main() { println(CheckString(GetString())) } 你们猜答案是
go(golang)之slice的小想法1
https://segmentfault.com/a/ slice,是go中一个很重要的主题。我们不用切片来表述,因为这里的切片特指的是数组的切片。 先给slice下个定义吧: Slice expressions construct a substring or slice from a string,
[leetcode]FindMinimuminRotatedSortedArrayII
code:https://play.golang.org/p/luj1fdu03F problem: https://oj.leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/ package main import ( "fmt" "math/rand" "sort" "time" ) //rotate数组方法一 func rotateArray1(a []int, pos int)