Create a gist now

Instantly share code, notes, and snippets.

Embed

An example where var err error; something, err = foo() is nicer than something, err := foo().

This is a less common situation.

	fd := os.Stdout
	if *output != "" {
		var err error
		fd, err = os.Create(*output)
		if err != nil {
			log.Fatalf("cover: %s", err)
		}
	}
	fd.Write(initialComments(content)) // Retain '// +build' directives.

vs

	fd := os.Stdout
	if *output != "" {
		fd2, err := os.Create(*output)
		if err != nil {
			log.Fatalf("cover: %s", err)
		}
		fd = fd2
	}
	fd.Write(initialComments(content)) // Retain '// +build' directives.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment