2014-06-29 16:52:21 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2015-06-12 03:46:06 +00:00
|
|
|
"runtime"
|
2014-06-29 16:52:21 +00:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func sleepytime() {
|
2014-11-24 23:57:52 +00:00
|
|
|
time.Sleep(5 * time.Millisecond)
|
2014-06-29 16:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func helloworld() {
|
|
|
|
fmt.Println("Hello, World!")
|
|
|
|
}
|
|
|
|
|
2014-07-10 23:07:39 +00:00
|
|
|
func testnext() {
|
2014-10-04 02:44:43 +00:00
|
|
|
var (
|
|
|
|
j = 1
|
|
|
|
f = 2
|
|
|
|
)
|
2014-06-29 16:52:21 +00:00
|
|
|
|
2014-10-08 03:35:57 +00:00
|
|
|
for i := 0; i <= 5; i++ {
|
2014-07-10 23:07:39 +00:00
|
|
|
j += j * (j ^ 3) / 100
|
2014-06-29 16:52:21 +00:00
|
|
|
|
2014-10-08 03:35:57 +00:00
|
|
|
if i == f {
|
|
|
|
fmt.Println("foo")
|
|
|
|
break
|
|
|
|
}
|
2014-06-29 16:52:21 +00:00
|
|
|
|
2014-11-24 23:57:52 +00:00
|
|
|
sleepytime()
|
2014-10-04 02:44:43 +00:00
|
|
|
}
|
|
|
|
|
2014-07-10 23:07:39 +00:00
|
|
|
helloworld()
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2015-04-19 22:11:33 +00:00
|
|
|
d := make(chan int)
|
|
|
|
testnext()
|
|
|
|
go testgoroutine(9, d)
|
|
|
|
<-d
|
|
|
|
fmt.Println("done")
|
|
|
|
}
|
|
|
|
|
|
|
|
// fix line
|
|
|
|
func testgoroutine(foo int, d chan int) {
|
|
|
|
d <- foo
|
2014-06-29 16:52:21 +00:00
|
|
|
}
|
2015-06-12 03:46:06 +00:00
|
|
|
|
|
|
|
func init() {
|
|
|
|
runtime.LockOSThread()
|
|
|
|
runtime.GOMAXPROCS(4)
|
|
|
|
}
|