Skip to content

Instantly share code, notes, and snippets.

@tigercallme
Last active October 20, 2017 13:26
Show Gist options
  • Save tigercallme/d4a4ae90a180a80dfa5cfeae2ee8bc5a to your computer and use it in GitHub Desktop.
Save tigercallme/d4a4ae90a180a80dfa5cfeae2ee8bc5a to your computer and use it in GitHub Desktop.

Revisions

  1. tigercallme revised this gist Oct 20, 2017. No changes.
  2. tigercallme revised this gist Oct 20, 2017. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion main.go
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,6 @@ for range time.Tick(30 * time.Millisecond) {
    doSomthing()
    }

    //time.Tick()返回的是一个channel,每隔指定的时间会有数据从channel中出来,for range不仅能遍历map,slice,array还能取出channel中数据,range前面可以不用变量接收,所以可以简写成上面的形式。
    //time.Tick()返回的是一个channel,每隔指定的时间会有数据从channel中出来,
    //for range不仅能遍历map,slice,array还能取出channel中数据,range前面可以不用变量接收,
    //所以可以简写成上面的形式。
  3. tigercallme created this gist Oct 20, 2017.
    5 changes: 5 additions & 0 deletions main.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    for range time.Tick(30 * time.Millisecond) {
    doSomthing()
    }

    //time.Tick()返回的是一个channel,每隔指定的时间会有数据从channel中出来,for range不仅能遍历map,slice,array还能取出channel中数据,range前面可以不用变量接收,所以可以简写成上面的形式。