generator = func(company string, department string, sn uint32) string{
// return "Gophers-RD-1"
return appendSn(company + "-" + department+ "-" , sn)
}
// return "Gophers-RD-1"
return appendSn(company + "-" + department+ "-" , sn)
}
2018-03-11
// return "Gophers-RD-1" 感觉这样写枉费了作者良苦用心
于是改为:
return appendSn(company + "-" + department+ "-" , sn)
于是改为:
return appendSn(company + "-" + department+ "-" , sn)
2018-03-11
最新回答 / 慕尼黑9152544
export GOPATH=/Users/fujiangren/Desktop/xiaochengxu/choujiangxitong/tools/go 2 export GOBIN=$GOPATH/bin 3 export PATH=$PATH:${GOPATH//://bin:}/bin
2018-03-11
指针的本质的地址
指针须声明类型
只可以**p,但不能有&&p
地址是只读的
&可抵消,即&a=a
空指针不能取指针值
指针须声明类型
只可以**p,但不能有&&p
地址是只读的
&可抵消,即&a=a
空指针不能取指针值
2018-03-11
package main
func main() {
var a int = 123
var b *int = &a //指针变量b
println(a) //值
println(&a) //地址
println(b) //值(本质也是一个地址)
println(&b) //地址
println(*b) //取指针值
}
func main() {
var a int = 123
var b *int = &a //指针变量b
println(a) //值
println(&a) //地址
println(b) //值(本质也是一个地址)
println(&b) //地址
println(*b) //取指针值
}
2018-03-11
func main() {
ch4 := make(chan int, 1)
for i := 0; i < 4; i++ {
select {
case e, ok := <-ch4:
if !ok {
fmt.Println("End.")
return
}
fmt.Println(e)
close(ch4)
default:
fmt.Println("No Data!")
ch4 <- 1
//fmt.Println("1")
}
}
}
ch4 := make(chan int, 1)
for i := 0; i < 4; i++ {
select {
case e, ok := <-ch4:
if !ok {
fmt.Println("End.")
return
}
fmt.Println(e)
close(ch4)
default:
fmt.Println("No Data!")
ch4 <- 1
//fmt.Println("1")
}
}
}
2018-03-09
func main() {
ia := []interface{}{byte(6), 'a', uint(10), int32(-4)}
switch v := ia[rand.Intn(4)%1+1]; interface{}(v).(type) {
case int32 :
fmt.Printf("Case A.")
case byte :
fmt.Printf("Case B.")
default:
fmt.Println("Unknown!")
}
}
我的答案
ia := []interface{}{byte(6), 'a', uint(10), int32(-4)}
switch v := ia[rand.Intn(4)%1+1]; interface{}(v).(type) {
case int32 :
fmt.Printf("Case A.")
case byte :
fmt.Printf("Case B.")
default:
fmt.Println("Unknown!")
}
}
我的答案
2018-03-09
哈哈 我的答案
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