<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>《Go coding in go way》的评论</title>
	<atom:link href="http://tonybai.com/2017/04/20/go-coding-in-go-way/feed/" rel="self" type="application/rss+xml" />
	<link>https://tonybai.com/2017/04/20/go-coding-in-go-way/</link>
	<description>一个程序员的心路历程</description>
	<lastBuildDate>Wed, 25 Mar 2026 09:21:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>作者：bigwhite</title>
		<link>https://tonybai.com/2017/04/20/go-coding-in-go-way/#comment-7228</link>
		<dc:creator>bigwhite</dc:creator>
		<pubDate>Fri, 29 Jun 2018 13:54:35 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2298#comment-7228</guid>
		<description>那只是一个demo代码，演示的是精妙的素数筛技巧罢了。比如我们要筛出100以内素数，如果在main goroutine执行sieve，当筛选完毕后，所有goroutine都会阻塞在从ch这个channel的send or recv 操作上。因此runtime会报panic。你可以 将sieve放到一个单独的goroutine中运行，就像下面这样：

func main() {
    go sieve()
    time.Sleep(time.Second * 100)
}</description>
		<content:encoded><![CDATA[<p>那只是一个demo代码，演示的是精妙的素数筛技巧罢了。比如我们要筛出100以内素数，如果在main goroutine执行sieve，当筛选完毕后，所有goroutine都会阻塞在从ch这个channel的send or recv 操作上。因此runtime会报panic。你可以 将sieve放到一个单独的goroutine中运行，就像下面这样：</p>
<p>func main() {<br />
    go sieve()<br />
    time.Sleep(time.Second * 100)<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：monkey</title>
		<link>https://tonybai.com/2017/04/20/go-coding-in-go-way/#comment-7227</link>
		<dc:creator>monkey</dc:creator>
		<pubDate>Fri, 29 Jun 2018 09:28:23 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2298#comment-7227</guid>
		<description>你好，素数筛那个问题，我试了下用Rob那个Go的代码运行出来，素数到时都筛选出来了，但是总是报死锁错误：all goroutines are asleep - deadlock!，可以解释下吗</description>
		<content:encoded><![CDATA[<p>你好，素数筛那个问题，我试了下用Rob那个Go的代码运行出来，素数到时都筛选出来了，但是总是报死锁错误：all goroutines are asleep &#8211; deadlock!，可以解释下吗</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：bigwhite</title>
		<link>https://tonybai.com/2017/04/20/go-coding-in-go-way/#comment-7224</link>
		<dc:creator>bigwhite</dc:creator>
		<pubDate>Thu, 21 Jun 2018 12:33:50 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2298#comment-7224</guid>
		<description>package main

import (
    &quot;fmt&quot;
)

const (
    a = 1
)

func main() {
    var n1 int16 = 5
    fmt.Println(n1 + a)
    var n2 int32 = 51
    fmt.Println(n2 + a)
}

运行这个程序：

$go run testconst.go
6
52

看到了吧，a这个常量的“类型”随着参与运算时的其他操作数的类型而自动变化，不需要显式转型，不会出现Compile error。这算是一个compiler sugar吧。</description>
		<content:encoded><![CDATA[<p>package main</p>
<p>import (<br />
    “fmt”<br />
)</p>
<p>const (<br />
    a = 1<br />
)</p>
<p>func main() {<br />
    var n1 int16 = 5<br />
    fmt.Println(n1 + a)<br />
    var n2 int32 = 51<br />
    fmt.Println(n2 + a)<br />
}</p>
<p>运行这个程序：</p>
<p>$go run testconst.go<br />
6<br />
52</p>
<p>看到了吧，a这个常量的“类型”随着参与运算时的其他操作数的类型而自动变化，不需要显式转型，不会出现Compile error。这算是一个compiler sugar吧。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：kyle</title>
		<link>https://tonybai.com/2017/04/20/go-coding-in-go-way/#comment-7223</link>
		<dc:creator>kyle</dc:creator>
		<pubDate>Thu, 21 Jun 2018 10:57:37 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2298#comment-7223</guid>
		<description>Go语言中constants只是数字

麻烦您 这句话能解释一下吗？</description>
		<content:encoded><![CDATA[<p>Go语言中constants只是数字</p>
<p>麻烦您 这句话能解释一下吗？</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：bigwhite</title>
		<link>https://tonybai.com/2017/04/20/go-coding-in-go-way/#comment-7133</link>
		<dc:creator>bigwhite</dc:creator>
		<pubDate>Mon, 19 Feb 2018 23:49:00 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2298#comment-7133</guid>
		<description>可以profile一下（go tool pprof）内存分配情况 https://golang.org/doc/diagnostics.html</description>
		<content:encoded><![CDATA[<p>可以profile一下（go tool pprof）内存分配情况 <a href="https://golang.org/doc/diagnostics.html" rel="nofollow">https://golang.org/doc/diagnostics.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：iikira</title>
		<link>https://tonybai.com/2017/04/20/go-coding-in-go-way/#comment-7132</link>
		<dc:creator>iikira</dc:creator>
		<pubDate>Mon, 19 Feb 2018 12:22:14 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2298#comment-7132</guid>
		<description>是这样的……我做个高并发网络请求，三百并发量，结果做出来的东西内存占用很大，检测goroutine数量上万……我猜测是context造成的</description>
		<content:encoded><![CDATA[<p>是这样的……我做个高并发网络请求，三百并发量，结果做出来的东西内存占用很大，检测goroutine数量上万……我猜测是context造成的</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：bigwhite</title>
		<link>https://tonybai.com/2017/04/20/go-coding-in-go-way/#comment-7131</link>
		<dc:creator>bigwhite</dc:creator>
		<pubDate>Mon, 19 Feb 2018 12:03:09 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2298#comment-7131</guid>
		<description>我对Goexit的理解也仅限于godoc上对Goexit的描述：https://golang.org/pkg/runtime/#Goexit  个人觉得在用户程序中尽量使用return，而不是runtime.Goexit。</description>
		<content:encoded><![CDATA[<p>我对Goexit的理解也仅限于godoc上对Goexit的描述：https://golang.org/pkg/runtime/#Goexit  个人觉得在用户程序中尽量使用return，而不是runtime.Goexit。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：iikira</title>
		<link>https://tonybai.com/2017/04/20/go-coding-in-go-way/#comment-7130</link>
		<dc:creator>iikira</dc:creator>
		<pubDate>Mon, 19 Feb 2018 05:53:15 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2298#comment-7130</guid>
		<description>你好，在goroutine里return和runtime.Goexit()有什么区别吗，我试了下return好像不会释放内存?</description>
		<content:encoded><![CDATA[<p>你好，在goroutine里return和runtime.Goexit()有什么区别吗，我试了下return好像不会释放内存?</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：bigwhite</title>
		<link>https://tonybai.com/2017/04/20/go-coding-in-go-way/#comment-6996</link>
		<dc:creator>bigwhite</dc:creator>
		<pubDate>Thu, 23 Nov 2017 08:48:32 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2298#comment-6996</guid>
		<description>s()不返回，goroutine不会结束。但是除非是代码bug，一般来说即便是网络超时，s()也会返回的，可能只是等的时间长了些罢了。</description>
		<content:encoded><![CDATA[<p>s()不返回，goroutine不会结束。但是除非是代码bug，一般来说即便是网络超时，s()也会返回的，可能只是等的时间长了些罢了。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：iikira</title>
		<link>https://tonybai.com/2017/04/20/go-coding-in-go-way/#comment-6995</link>
		<dc:creator>iikira</dc:creator>
		<pubDate>Thu, 23 Nov 2017 08:04:12 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2298#comment-6995</guid>
		<description>有个问题 ，文章最后的
go func() {
      c1 := make(chan result)
      go func() {
        c1 &lt;-s()// 假如s()一直没有返回结果，那这个goroutine会不会结束掉呢
      }
      select {
        case v := &lt;-c1:
             c &lt;-v
        case &lt;-ctx.Done():
        // cancel this in-flight request by closing its connection.
      }
    }()</description>
		<content:encoded><![CDATA[<p>有个问题 ，文章最后的<br />
go func() {<br />
      c1 := make(chan result)<br />
      go func() {<br />
        c1 &lt;-s()// 假如s()一直没有返回结果，那这个goroutine会不会结束掉呢<br />
      }<br />
      select {<br />
        case v := &lt;-c1:<br />
             c &lt;-v<br />
        case &lt;-ctx.Done():<br />
        // cancel this in-flight request by closing its connection.<br />
      }<br />
    }()</p>
]]></content:encoded>
	</item>
</channel>
</rss>
