<?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错误处理新提案的一个想法：?操作符这样用行不行》的评论</title>
	<atom:link href="http://tonybai.com/2025/02/08/personal-idea-about-using-question-mark-operator-in-go-error-handling-new-proposal/feed/" rel="self" type="application/rss+xml" />
	<link>https://tonybai.com/2025/02/08/personal-idea-about-using-question-mark-operator-in-go-error-handling-new-proposal/</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>作者：betuli</title>
		<link>https://tonybai.com/2025/02/08/personal-idea-about-using-question-mark-operator-in-go-error-handling-new-proposal/#comment-7804</link>
		<dc:creator>betuli</dc:creator>
		<pubDate>Mon, 10 Feb 2025 18:01:31 +0000</pubDate>
		<guid isPermaLink="false">https://tonybai.com/?p=4481#comment-7804</guid>
		<description>感觉还是结合着 err 会好一点
```go
func foo() (int, error) {
	return 1, errors.New(&quot;error&quot;)
}

var x int
x = foo() ? {
	// nothing
}
fmt.Println(x)
```
赋值的顺序是怎样，这里是输出 1 还是 0
还有就是有关指针
```go
var x *int
*x = foo() ? // returns the error
// not reached
```</description>
		<content:encoded><![CDATA[<p>感觉还是结合着 err 会好一点<br />
“`go<br />
func foo() (int, error) {<br />
	return 1, errors.New(“error”)<br />
}</p>
<p>var x int<br />
x = foo() ? {<br />
	// nothing<br />
}<br />
fmt.Println(x)<br />
“`<br />
赋值的顺序是怎样，这里是输出 1 还是 0<br />
还有就是有关指针<br />
“`go<br />
var x *int<br />
*x = foo() ? // returns the error<br />
// not reached<br />
“`</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：he11o</title>
		<link>https://tonybai.com/2025/02/08/personal-idea-about-using-question-mark-operator-in-go-error-handling-new-proposal/#comment-7803</link>
		<dc:creator>he11o</dc:creator>
		<pubDate>Sat, 08 Feb 2025 01:14:40 +0000</pubDate>
		<guid isPermaLink="false">https://tonybai.com/?p=4481#comment-7803</guid>
		<description>```golang
// T?
if T ==nil { return T }

// f() ?
if x := f(); x == nil {
 return x
}

// x1 := f() ?
if x1, x := f(); x == nil {
 return x
}


// x1,x2 := f() ?
if x1, x2, x := f(); x == nil {
 return x
}


// x1 := f() ? { return errors.New(&quot;new error&quot;) }
if x1, x := f(); x == nil {
 return errors.New(&quot;new error&quot;)
}

// x1 := f() ? x { return errors.Wrap(x, &quot;wrap error&quot;) }
if x1, x := f(); x == nil {
 return errors.Wrap(x, &quot;wrap error&quot;)
}

// x1 := f() ? x { log.Print(x) }
if x1, x := f(); x == nil {
 log.Print(x)
}
```</description>
		<content:encoded><![CDATA[<p>“`golang<br />
// T?<br />
if T ==nil { return T }</p>
<p>// f() ?<br />
if x := f(); x == nil {<br />
 return x<br />
}</p>
<p>// x1 := f() ?<br />
if x1, x := f(); x == nil {<br />
 return x<br />
}</p>
<p>// x1,x2 := f() ?<br />
if x1, x2, x := f(); x == nil {<br />
 return x<br />
}</p>
<p>// x1 := f() ? { return errors.New(“new error”) }<br />
if x1, x := f(); x == nil {<br />
 return errors.New(“new error”)<br />
}</p>
<p>// x1 := f() ? x { return errors.Wrap(x, “wrap error”) }<br />
if x1, x := f(); x == nil {<br />
 return errors.Wrap(x, “wrap error”)<br />
}</p>
<p>// x1 := f() ? x { log.Print(x) }<br />
if x1, x := f(); x == nil {<br />
 log.Print(x)<br />
}<br />
“`</p>
]]></content:encoded>
	</item>
</channel>
</rss>
