Skip to content

Instantly share code, notes, and snippets.

@tonidy
Created January 21, 2026 18:02
Show Gist options
  • Select an option

  • Save tonidy/b3ba98d790410cf236970d1b1d7c6c16 to your computer and use it in GitHub Desktop.

Select an option

Save tonidy/b3ba98d790410cf236970d1b1d7c6c16 to your computer and use it in GitHub Desktop.
Learn Go 1
{"front": "What is the command to create a new Go module?", "back": "go mod init <module-name>"}
{"front": "How do you declare a variable with explicit type in Go?", "back": "var name string = \"value\" or var name string"}
{"front": "What is the short variable declaration syntax in Go?", "back": "name := \"value\" (type is inferred, only works inside functions)"}
{"front": "How do you define a function in Go?", "back": "func functionName(param type) returnType { ... }"}
{"front": "What are the basic data types in Go?", "back": "bool, string, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, byte, rune, float32, float64, complex64, complex128"}
{"front": "How do you create a slice in Go?", "back": "Using make: s := make([]int, length, capacity) or literal: s := []int{1, 2, 3}"}
{"front": "What is the difference between array and slice in Go?", "back": "Arrays have fixed size [5]int, slices are dynamic []int. Slices are references to underlying arrays."}
{"front": "How do you iterate over a slice or array in Go?", "back": "for i, v := range slice { ... } where i is index and v is value, or for i := 0; i < len(slice); i++ { ... }"}
{"front": "How do you create a map in Go?", "back": "m := make(map[keyType]valueType) or m := map[string]int{\"key\": 1}"}
{"front": "What is a pointer in Go and how do you declare one?", "back": "A pointer holds the memory address of a value. Declare with *Type, get address with &variable, dereference with *pointer"}
{"front": "How do you define a struct in Go?", "back": "type StructName struct { Field1 type1; Field2 type2 }"}
{"front": "What is a goroutine and how do you start one?", "back": "A goroutine is a lightweight thread managed by Go runtime. Start with: go functionName() or go func() { ... }()"}
{"front": "How do you create a channel in Go?", "back": "ch := make(chan Type) for unbuffered, or ch := make(chan Type, bufferSize) for buffered"}
{"front": "What is the defer keyword in Go?", "back": "defer postpones the execution of a function until the surrounding function returns. Multiple defers execute in LIFO order."}
{"front": "How do you handle errors in Go?", "back": "Functions return error as last return value. Check with: if err != nil { ... }. Errors are created with errors.New() or fmt.Errorf()"}
{"front": "What is an interface in Go and how do you define one?", "back": "An interface is a collection of method signatures. type InterfaceName interface { MethodName() returnType }. Types implement interfaces implicitly."}
{"front": "What is the difference between buffered and unbuffered channels?", "back": "Unbuffered channels block until both sender and receiver are ready. Buffered channels only block when buffer is full (send) or empty (receive)."}
{"front": "How do you close a channel and check if it's closed?", "back": "Close with: close(ch). Check with: value, ok := <-ch where ok is false if channel is closed and empty."}
{"front": "What are method receivers in Go?", "back": "Methods with receivers attach functions to types: func (r ReceiverType) methodName() { ... }. Can be value (r Type) or pointer (*r Type) receivers."}
{"front": "What is the select statement used for in Go?", "back": "select lets a goroutine wait on multiple channel operations, executing the first one that's ready. Similar to switch but for channels."}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment