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

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.

主站蜘蛛池模板: 丰镇市| 庐江县| 永川市| 逊克县| 藁城市| 福安市| 平度市| 鄱阳县| 万荣县| 托里县| 澄江县| 宁德市| 炉霍县| 大冶市| 尖扎县| 秭归县| 澜沧| 蒲江县| 长丰县| 平湖市| 伊通| 登封市| 会泽县| 东平县| 萨迦县| 图们市| 华亭县| 澳门| 恩施市| 定结县| 改则县| 瑞丽市| 内黄县| 灌南县| 大同市| 金门县| 长丰县| 鄯善县| 延吉市| 景东| 鹤庆县|