An overview of Go syntax and features.
7147
201
964

outer_var in the outer func wasn't changed because the anonymous inner function hadn't been called yet.

// Closures: don't mutate outer vars, instead redefine them!
func outer() (func() int, int) {
	outer_var := 2 // NOTE outer_var is outside inner's scope
	inner := func() int {
		outer_var += 99  // attempt to mutate outer_var
		return outer_var // => 101 (but outer_var is a newly redefined
		//  variable visible only inside inner)
	}
	return inner, outer_var // => 101, 2 (still!)
}

I saw you made updates on the README file, but some people may also read your pdf file.

Would you be looking to add common Go modules to this guide, or is it no longer being maintained? I'd be happy to contribute.

Could you add information about generic of Golang 1.18 for cheat sheet. Tks!

This repo is really useful when I want to check the syntax of Go.

I have translated a chinese version of this repo.
golang-cheat-sheet-cn

If you'd like to to add other languages's translation into your repo, I can open a PR.

Thanks.

I wish there was a section on strings. How to index them, some formatting tricks, etc.

An example can be found here

Please add break & continue that controls the for loop. Thx.

I have printed the pages, but there are no page numbers. In my opinion, the pdf and odt should be part of a release rather than being stored in git.

There is an example regarding pointers, but there is no comment that describes when to use pointers.

Hi,

I believe the example about Closures is not quite correct. The comment says that the returned outer_var is still 2 because inner() has only modified a copy of it. However, when outer() returns, inner() has not been called yet, and this is why outer_var is 2 at that time. When inner is executed before outer() returns, then outer_var is returned as 101. See this Playground test code: https://play.golang.org/p/e_wktwN6me

Thanks,
Christoph

Hello,

Please explain how one can replace map[string]interface{} functionality with an anonymous struct

Goroutines are lightweight threads (managed by Go, not OS threads).

Actually, the way goroutines are implemented are subject to the specific implementation. With gccgo, it does (or did?) use an OS thread for each goroutine.
from http://www.airs.com/blog/archives/448 :
"
On the functionality side, the gccgo library uses a single operating system thread for each goroutine. That is not what 6g/8g do: they multiplex goroutines onto operating system threads. Multiplexing is more efficient for a language like Go, and I need to change gccgo to work that way.
"

Hello, we have indexd this cheat sheet to awesome-cheatsheet

Thank You !!! ๐Ÿš€ ๐Ÿš€ ๐Ÿš€

You don't need to include fmt package for printing "hello world"

package main

func main(){
  println("Hello world")
}

Personally, I think adding a "comment" section will be better for this cheat sheet.