哈哈 我的答案
type Cat struct{
name string
age int
address string
}
func (cat * Cat)Grow(){
cat.age++
}
func (cat * Cat)Move(str string) string{
var oldaddress string
oldaddress,cat.address = cat.address,str
return oldaddress
}
type Cat struct{
name string
age int
address string
}
func (cat * Cat)Grow(){
cat.age++
}
func (cat * Cat)Move(str string) string{
var oldaddress string
oldaddress,cat.address = cat.address,str
return oldaddress
}
2018-03-09
要编写一个函数
func myfunc(company string, department string, sn uint32) string{
return appendSn(company + "-" + department + "-",sn)
}
赋值给 generator
generator = myfunc
func myfunc(company string, department string, sn uint32) string{
return appendSn(company + "-" + department + "-",sn)
}
赋值给 generator
generator = myfunc
2018-03-09
package main
import (
"fmt"
"time"
)
func main() {
go func() {
fmt.Println("1")
}()
go func() {
time.Sleep(100 * time.Millisecond)
fmt.Println("2")
}()
go func() {
time.Sleep(300 * time.Millisecond)
fmt.Println("3")
}()
time.Sleep(500 * time.Millisecond)
}
import (
"fmt"
"time"
)
func main() {
go func() {
fmt.Println("1")
}()
go func() {
time.Sleep(100 * time.Millisecond)
fmt.Println("2")
}()
go func() {
time.Sleep(300 * time.Millisecond)
fmt.Println("3")
}()
time.Sleep(500 * time.Millisecond)
}
2018-02-28
func (p *Person) Move(newAddress string) string { ...}
Person不带*,实参不会 改变
Person不带*,实参不会 改变
2018-02-27
cap :就是在数组长度减去切片位置的起始值的总和得出最终结果。
var num =[6]int{1,2,3,5,6}
var slice1 = num[2:5]
var slice2 = slice1[1:3]
cap(slice2) //6-2-1=3
var num =[6]int{1,2,3,5,6}
var slice1 = num[2:5]
var slice2 = slice1[1:3]
cap(slice2) //6-2-1=3
2018-02-26