News for hackers. Stuff that matters.
Re:Why I love Go by Xeoncross on Wednesday December 06, 2017 @10:58AM (#15862056)
You almost always defined your variables. None of this `foo, err := getFoo()` nonsense.

Most functions return an error so err is already defined:

    func doIt(a, b) (result string, err error) { ... }
Then you are free to reuse err as needed.

        func doIt(a, b int) (result string, err error) {

		var x, y string

		x, err = doA(a)
		if err != nil {
			return
		}

		y, err = doB(b)
		if err != nil {
			return
		}

		result = x + y
		return
	}

There are no comments on this comment yet.