锘??xml version="1.0" encoding="utf-8" standalone="yes"?>美女网站在线,国产精品一区二区不卡视频,精品五月天久久http://www.aygfsteel.com/oathleo/鍛嗗湪涓婃搗zh-cnSat, 03 May 2025 08:27:08 GMTSat, 03 May 2025 08:27:08 GMT60golang chan 瓚呮椂http://www.aygfsteel.com/oathleo/archive/2013/12/24/407964.htmloathleooathleoTue, 24 Dec 2013 05:03:00 GMThttp://www.aygfsteel.com/oathleo/archive/2013/12/24/407964.htmlhttp://www.aygfsteel.com/oathleo/comments/407964.htmlhttp://www.aygfsteel.com/oathleo/archive/2013/12/24/407964.html#Feedback0http://www.aygfsteel.com/oathleo/comments/commentRss/407964.htmlhttp://www.aygfsteel.com/oathleo/services/trackbacks/407964.htmlpackage main

import (
    "fmt"
    "time"
)

var ch chan int = make(chan int, 1)

func main() {
    go aaa()

    select {
    case <-ch: //鎷垮埌閿?/span>
        fmt.Println("call")
    case <-time.After(5 * time.Second): //瓚呮椂5s
        fmt.Println("5 sec call")
    }
}

func aaa() {
    time.Sleep(time.Second * 3)
    ch <- 1
}

oathleo 2013-12-24 13:03 鍙戣〃璇勮
]]>
golang 涔?鎺ュ彛http://www.aygfsteel.com/oathleo/archive/2013/12/22/407869.htmloathleooathleoSun, 22 Dec 2013 04:45:00 GMThttp://www.aygfsteel.com/oathleo/archive/2013/12/22/407869.htmlhttp://www.aygfsteel.com/oathleo/comments/407869.htmlhttp://www.aygfsteel.com/oathleo/archive/2013/12/22/407869.html#Feedback1http://www.aygfsteel.com/oathleo/comments/commentRss/407869.htmlhttp://www.aygfsteel.com/oathleo/services/trackbacks/407869.htmlconn, err = ln.Accept()
go handleConnection(conn)鐪嬪埌榪欓噷鎴戞浘緇忔湁涓枒闂紝涓轟粈涔堜笉鏄?nbsp; handleConnection(&conn) ?

涓嬮潰榪欎釜渚嬪瓙瑙i噴榪欎釜闂

package main

import (
    "fmt"
)

type Interface interface {
    say() string
}

type Object struct {
}

func (this *Object) say() string {
    return "hello"
}

func do(i Interface) string {
    return i.say()
}

func main() {
    o := Object{}
    fmt.Println(do(&o))
    fmt.Printf("CCCCCCCCCCC:%T", o)
}

鍑芥暟鐨勫弬鏁頒互鎺ュ彛瀹氫箟錛岀紪璇戝櫒浼?xì)鑷繁鍒ゆ柇鍙傛暟鏄璞q樻槸瀵硅薄鐨勬寚閽?br /> 姣斿錛宻ay鏄寚閽堜笂鐨勬柟娉曪紝鎵浠o鍙帴鍙?span style="background-color: #eeeeee;">Object鐨勬寚閽堝仛鍙傛暟錛宒o(o)鏄紪璇戜笉榪囩殑

鎵浠ョ湅鍒板簱閲屾帴鍙e仛鍙傛暟綾誨瀷瀹氫箟鐨勬椂鍊欙紝鍙互綆鍗曡涓猴紝榪欎釜鎺ュ彛鑲畾鏄釜瀵硅薄鎸囬拡錛堣櫧鐒朵篃鍙互鐢ㄥ璞★紝鍗曚及璁℃病鏈夊摢涓被搴撲細(xì)鐢級(jí)

渚嬪錛?br /> conn, err = ln.Accept()
go handleConnection(conn)

榪欓噷conn鏄釜鎺ュ彛錛屼笉闇瑕?nbsp;go handleConnection(&conn)

oathleo 2013-12-22 12:45 鍙戣〃璇勮
]]>
golang瀹氭椂瀹氱偣浠誨姟http://www.aygfsteel.com/oathleo/archive/2013/12/19/407774.htmloathleooathleoThu, 19 Dec 2013 08:15:00 GMThttp://www.aygfsteel.com/oathleo/archive/2013/12/19/407774.htmlhttp://www.aygfsteel.com/oathleo/comments/407774.htmlhttp://www.aygfsteel.com/oathleo/archive/2013/12/19/407774.html#Feedback0http://www.aygfsteel.com/oathleo/comments/commentRss/407774.htmlhttp://www.aygfsteel.com/oathleo/services/trackbacks/407774.htmlpackage main

import (
    "fmt"
    "mag/common"
    "time"
)

func main() {
    c := make(chan bool, 10)

    tt := common.GetTodayGivenTime("161300")
    dd := common.SinceNow(tt)
    time.AfterFunc(dd, func() { //闈為樆濉?br />        //鍚庣畫姣?4灝忔椂寤虹珛鐩綍
        ticker24h := time.NewTicker(5 * time.Second)
        for {
            select {
            case <-ticker24h.C:
                fmt.Println("print")
            }
        }
    })

    <-c
}

oathleo 2013-12-19 16:15 鍙戣〃璇勮
]]>
golang append鏃秙lice len 鍜?caphttp://www.aygfsteel.com/oathleo/archive/2013/11/20/406595.htmloathleooathleoWed, 20 Nov 2013 10:48:00 GMThttp://www.aygfsteel.com/oathleo/archive/2013/11/20/406595.htmlhttp://www.aygfsteel.com/oathleo/comments/406595.htmlhttp://www.aygfsteel.com/oathleo/archive/2013/11/20/406595.html#Feedback1http://www.aygfsteel.com/oathleo/comments/commentRss/406595.htmlhttp://www.aygfsteel.com/oathleo/services/trackbacks/406595.html
澹版槑:
婧恠lice= src
娣誨姞slice = app
緇撴灉slice=tar
append鏃?/div>
len tar === len src +   len app
1錛夊鏋渓en(src) + len(app) <= cap(src)    cap tar  =   cap(src)
2錛夊惁鍒?nbsp;
      a) len(src) + len(app) > 2* cap(src)     cap tar  =   len(src) + len(app)
      b) cap(src) < len(src) + len(app) <= 2* cap(src)    cap tar = 2* cap(src)
    data := make([]int, 10, 20)
    data[0] = 1
    data[1] = 2

    dataappend := make([]int, 12, 30)//淇敼榪欎釜len 
    dataappend[0] = 1
    dataappend[1] = 2

    result := append(data, dataappend)

    result[0] = 99
    result[11] = 98

    fmt.Println("length:", len(data), "cap:", cap(data), ":", data)
    fmt.Println("result length:", len(result), "cap:", cap(result), ":", result)
    fmt.Println("length:", len(dataappend), "cap:", cap(dataappend), ":", dataappend)


oathleo 2013-11-20 18:48 鍙戣〃璇勮
]]>golang slice鍒嗗壊鍜宎ppend copy榪樻槸寮曠敤http://www.aygfsteel.com/oathleo/archive/2013/11/20/406594.htmloathleooathleoWed, 20 Nov 2013 10:46:00 GMThttp://www.aygfsteel.com/oathleo/archive/2013/11/20/406594.htmlhttp://www.aygfsteel.com/oathleo/comments/406594.htmlhttp://www.aygfsteel.com/oathleo/archive/2013/11/20/406594.html#Feedback1http://www.aygfsteel.com/oathleo/comments/commentRss/406594.htmlhttp://www.aygfsteel.com/oathleo/services/trackbacks/406594.html1.slice1:= slice[0:2]
寮曠敤錛岄潪澶嶅埗錛屾墍浠ヤ換浣曞slice1鎴杝lice鐨勪慨鏀歸兘浼?xì)濯?jiǎng)鍝嶅鏂?/div>
data := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}
data1 := data[0:2]
data1[0] = 99
fmt.Println(data1)
fmt.Println(data)
[99 2]
[99 2 3 4 5 6 7 8 9 0]
2.append
append 姣旇緝鐗規(guī)畩
澹版槑:
婧恠lice= src
娣誨姞slice = app
緇撴灉slice=tar
1錛夊鏋渓en(src) + len(app) <= cap(src)  src鍜宼ar 鏄寚鍚戝悓涓鏁版嵁寮曠敤 錛屽嵆淇敼src鎴杢ar錛屼細(xì)褰卞搷瀵規(guī)柟
2錛夊惁鍒?tar 鏄痗opy鐨勬柟寮?nbsp;src + app 錛?span style="color: #ff0000; ">鍗充慨鏀箂rc鎴杢ar錛屼笉浼?xì)濯?jiǎng)鍝嶅鏂?/span>
鏃犺鍝鎯呭喌涓嶄細(xì)褰卞搷app錛屽洜涓篴pp閮戒細(xì)鐢╟opy鐨勬柟寮忚繘鍏ar
 
func test2() {
data := make([]int, 10, 20)
data[0] = 1
data[1] = 2
dataappend := make([]int, 10, 20)//len <=10 鍒?nbsp; result[0] = 99 浼?褰卞搷婧怱lice
dataappend[0] = 1
dataappend[1] = 2
result := append(data, dataappend...)
result[0] = 99
result[11] = 98
fmt.Println("length:", len(data), ":", data)
fmt.Println("length:", len(result), ":", result)
fmt.Println("length:", len(dataappend), ":", dataappend)
}


oathleo 2013-11-20 18:46 鍙戣〃璇勮
]]>golang 涔? 鍘繪帀瀹氶暱鏁扮粍閲岀殑0 []byte 杞?stringhttp://www.aygfsteel.com/oathleo/archive/2013/11/19/406513.htmloathleooathleoTue, 19 Nov 2013 02:16:00 GMThttp://www.aygfsteel.com/oathleo/archive/2013/11/19/406513.htmlhttp://www.aygfsteel.com/oathleo/comments/406513.htmlhttp://www.aygfsteel.com/oathleo/archive/2013/11/19/406513.html#Feedback0http://www.aygfsteel.com/oathleo/comments/commentRss/406513.htmlhttp://www.aygfsteel.com/oathleo/services/trackbacks/406513.html index := bytes.IndexByte(buf_PN, 0)
rbyf_pn := buf_PN[0:index]


oathleo 2013-11-19 10:16 鍙戣〃璇勮
]]>
golang涔?windows涓嬫潃榪涚▼http://www.aygfsteel.com/oathleo/archive/2013/11/15/406377.htmloathleooathleoFri, 15 Nov 2013 06:07:00 GMThttp://www.aygfsteel.com/oathleo/archive/2013/11/15/406377.htmlhttp://www.aygfsteel.com/oathleo/comments/406377.htmlhttp://www.aygfsteel.com/oathleo/archive/2013/11/15/406377.html#Feedback4http://www.aygfsteel.com/oathleo/comments/commentRss/406377.htmlhttp://www.aygfsteel.com/oathleo/services/trackbacks/406377.html c := exec.Command("taskkill.exe", "/f", "/im", "test.exe")
err := c.Start()


oathleo 2013-11-15 14:07 鍙戣〃璇勮
]]>
golang slice Append http://www.aygfsteel.com/oathleo/archive/2013/11/05/406016.htmloathleooathleoTue, 05 Nov 2013 08:39:00 GMThttp://www.aygfsteel.com/oathleo/archive/2013/11/05/406016.htmlhttp://www.aygfsteel.com/oathleo/comments/406016.htmlhttp://www.aygfsteel.com/oathleo/archive/2013/11/05/406016.html#Feedback0http://www.aygfsteel.com/oathleo/comments/commentRss/406016.htmlhttp://www.aygfsteel.com/oathleo/services/trackbacks/406016.html
鍒囩墖s1涓婅褰曠殑鍒囩墖淇℃伅澶嶅埗緇檚2錛?br />
1.濡傛灉s1鎸囧悜鐨勫簳灞俛rray闀垮害涓嶅錛宎ppend鐨勮繃紼嬩細(xì)鍙戠敓濡備笅鎿嶄綔錛氬唴瀛樹腑涓嶄粎鏂板紑杈熶竴鍧楀尯鍩熷瓨鍌╝ppend鍚庣殑鍒囩墖淇℃伅錛岃屼笖闇瑕佹柊寮杈熶竴鍧楀尯鍩熷瓨鍌ㄥ簳灞俛rray錛堝鍒跺師鏉ョ殑array鑷寵繖鍧楁柊array涓級(jí)錛屾渶鍚庡啀append鏂版暟鎹繘鏂癮rray涓紝榪欐牱錛宻2鎸囧悜鏂癮rray銆?br />
2.濡傛灉s1鎸囧悜鐨勫簳灞俛rray闀垮害澶?
s2鍜宻1鎸囧悜鍚屼竴涓猘rray錛宎ppend鐨勭粨鏋滄槸鍐呭瓨涓柊寮杈熶竴涓尯鍩熷瓨鍌ㄦ柊鍒囩墖淇℃伅銆?br />
寮杈熶竴鍧楀尯鍩熷瓨鍌ㄥ簳灞俛rray 浣跨敤涓嬮潰鐨勭瓥鐣ワ細(xì)
1.濡傛灉 澧炲姞鐨?len < s鐨刢ap 鍒?鏂皊鐨刢ap*2
2.濡傛灉 澧炲姞鐨?len > s鐨刢ap 鍒?鏂皊鐨刢ap = 鑰乧ap + 澧炲姞鏁版嵁鐨?len

oathleo 2013-11-05 16:39 鍙戣〃璇勮
]]>
golang 瀹氭椂http://www.aygfsteel.com/oathleo/archive/2013/10/10/404842.htmloathleooathleoThu, 10 Oct 2013 07:07:00 GMThttp://www.aygfsteel.com/oathleo/archive/2013/10/10/404842.htmlhttp://www.aygfsteel.com/oathleo/comments/404842.htmlhttp://www.aygfsteel.com/oathleo/archive/2013/10/10/404842.html#Feedback0http://www.aygfsteel.com/oathleo/comments/commentRss/404842.htmlhttp://www.aygfsteel.com/oathleo/services/trackbacks/404842.html

 // (A)
time.AfterFunc(5 * time.Minute, func() {
    fmt.Printf("expired")
}

// (B) create a Timer object
timer := time.NewTimer(5 * time.Minute)
<-timer.C
fmt.Printf("expired")

// (C) time.After() returns timer.C internally
<-time.After(5 * time.Minute)
fmt.Printf("expired")


oathleo 2013-10-10 15:07 鍙戣〃璇勮
]]>
golang 闈炵紦鍐查氶亾 recv 鐨勬搷浣?鑲畾 鍦?send 鎿嶄綔 涔嬪墠鍙戠敓http://www.aygfsteel.com/oathleo/archive/2013/10/10/404830.htmloathleooathleoThu, 10 Oct 2013 02:56:00 GMThttp://www.aygfsteel.com/oathleo/archive/2013/10/10/404830.htmlhttp://www.aygfsteel.com/oathleo/comments/404830.htmlhttp://www.aygfsteel.com/oathleo/archive/2013/10/10/404830.html#Feedback0http://www.aygfsteel.com/oathleo/comments/commentRss/404830.htmlhttp://www.aygfsteel.com/oathleo/services/trackbacks/404830.html 涓瀹氫細(xì)鍦? “鍚戦氶亾鍙戦佹暟鎹?#8221;鐨勬搷浣滃畬鎴愬墠鍙戠敓銆?br />
package main

import (
    "fmt"
)

var c = make(chan int)
var str string

func ready() {
    str = "abc"
    fmt.Println("ready1")
    <-c //get
    fmt.Println("ready2")
}

func main() {
    go ready()
    c <- 1 //put
    fmt.Println(str)
}

ready1
ready2
abc


oathleo 2013-10-10 10:56 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 崇文区| 襄城县| 郸城县| 井研县| 团风县| 军事| 天长市| 潮安县| 镇安县| 乐都县| 武定县| 保靖县| 塔河县| 盐城市| 海淀区| 米脂县| 上虞市| 开鲁县| 陆川县| 闽侯县| 伽师县| 分宜县| 兰州市| 锡林郭勒盟| 永康市| 洪江市| 福海县| 汉沽区| 衢州市| 威海市| 田东县| 徐闻县| 手游| 彩票| 沙湾县| 元谋县| 高州市| 铜陵市| 依兰县| 乌审旗| 琼中|