gpt4 book ai didi

go - Go 编程语言中的异常支持

转载 作者:数据小太阳 更新时间:2023-10-29 03:43:48 26 4
gpt4 key购买 nike

一些消息来源说 Go 出于性能原因不支持异常,但其他一些消息来源说 Google Team 实现了一些。 Go 当前的异常支持是什么?

最佳答案

Go 没有异常(exception),that is a design decision ,不基于性能:

We believe that coupling exceptions to a control structure, as in the try-catch-finally idiom, results in convoluted code. It also tends to encourage programmers to label too many ordinary errors, such as failing to open a file, as exceptional.

Go takes a different approach. For plain error handling, Go's multi-value returns make it easy to report an error without overloading the return value. A canonical error type, coupled with Go's other features, makes error handling pleasant but quite different from that in other languages.

关于go - Go 编程语言中的异常支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51389364/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com