官术网_书友最值得收藏!

Naming the return values of a Go function

Unlike C, Go allows you to name the return values of a Go function. Additionally, when such a function has a return statement without any arguments, the function automatically returns the current value of each named return value. Note that such functions return their values in the order they were declared in the definition of the function.

Naming return values is a very handy Go feature that can save you from various types of bugs, so use it.

My personal advice is this: name the return values of your functions unless there is a very good reason not to do so.

主站蜘蛛池模板: 贵溪市| 林州市| 淮北市| 沭阳县| 车致| 岫岩| 景泰县| 黎平县| 茌平县| 保定市| 安顺市| 东阿县| 乌苏市| 谷城县| 鹤岗市| 天等县| 嘉定区| 汉中市| 瑞安市| 云南省| 潞城市| 彭泽县| 富源县| 墨脱县| 瑞金市| 定陶县| 高州市| 钟山县| 称多县| 黔西| 兴宁市| 芜湖市| 夏邑县| 西峡县| 嘉兴市| 万全县| 伊春市| 达尔| 东源县| 凤山县| 大宁县|