ultimate-go icon indicating copy to clipboard operation
ultimate-go copied to clipboard

This repo contains my notes on working with Go and computer systems.

Motivation

This repo contains my notes on work with Go and computer systems

Table of Contents

  • Language Specification

    • Syntax

      • Variables: Zero value concept | Initialization | Const
      • Constant: Initialization | iota
      • Conversions: Conversion

      Struct: Declare_Initialize | Name And Anonymous type Field | Field Function| Iterate Field Name And Value | Selector and Promoted | Method Set

      • Struct Tags: Wiki | Code | Tag-Doc
      • Pointer:
        • Passing by value | Escape analysis | Stack space

      Function: Initialization | argument | multiple returns | named return

      • Build-in types: Built-in types
      • statement: statement | if else | for | switch | select | go
    • Data Structures

      • Enum: Enum
      • Array: CPU Cache | TLB | Initialization | Iteration | Type array | Contiguous memory allocation
      • Slice: Initialization | Length vs Capacity | Reference Type | Appending | Slice of Slice | Map | Reduce | Filter | Include | All|Any
      • Map: Initialization | Iteration | Deleting | Finding | Restriction
      • Channel: Declare | Iteration | Exit | send statements |receive operations
    • Decoupling

      • Method:
        • Value and Pointer Receiver Call | wiki
        • Value and Pointer Semantics
        • Methods are just functions | Function variable
        • closures
      • Interface:
        • Declaring |Type assertions| Concrete type vs Interface type| Polymorphic function
      • Embedding:
        • Declaring fields, NOT Embedding
        • Embedding type | Inner type promotion
        • Embedded type and Interface
        • Outer and inner type implementing the same Interface
      • Exporting:
        • Exported identifier
        • Accessing a value of an unexported identifier
        • Unexported fields from an exported struct
    • Dependency management Go Modules

    • Error Handling

      • Default error values
      • Error variables | best practices
      • Type as context
      • Wrapping Errors
    • Context

      • Store and retrieve values from a context
      • WithCancel
      • WithDeadline
      • WithTimeout
  • Concurrency LearnConcurrency

    • Goroutine
      • asynchronous network IO
    • Channel
      • Guideline
      • ping_pong
      • multiplexing
      • waitgroup
      • mutex
      • worker_pool
      • Select
  • Diagnostics Profiling

    • Diagnostics Diagnostics
    • Profiling code
    • Stack Trace: Review
    • GoLand Debug: GoLand Debug | blog
  • Testing

    • Testing:
      • Basic Unit Test
      • Web Server
      • Mock | Mock Server
    • Fuzzing
  • Design Pattern Design Patterns | javatpoint

    • SOLID: SOLID
    • Creational
    • Structual
      • Adapter: wiki | code | best practices
      • *Bridge: wiki | code | best practices
      • Composite: wiki | code | best practices
      • *Decorator: wiki | code | best practices
      • Facade: wiki | code | best practices
      • Flyweight: todowiki | code | best practices
      • Proxy (network proxy): wiki | code | best practices
    • Behavioral
      • *Chain of responsibility: wiki | code | best practices
      • Command: todo wiki | code | best practices
      • *Interpreter: todowiki | code | best practices
      • *Iterator: wiki | code | best practices
      • Mediator: todowiki | code | best practices
      • Memento: todowiki | code | best practices
      • Observer: todowiki | code | best practices
      • State: todowiki | code | best practices
      • *Strategy: wiki | code | best practices
      • Template method : todowiki | code | best practices
      • Visitor: todowiki | code | best practices
    • Composition: Guideline
      • Conversion:
        • Interface Conversions | Type Assertion
        • Runtime Type Assertion
          Algorithms Algorithms
    • Data Structures
    • Graph algorithms
      • Searching:
    • shortest path:
    • Sorting:
    • Maths algorithms
      • Binary GCD algorithm | (wiki)
      • Closest pairs | (wiki)
      • FastPower | (wiki)
      • Fibonacci | (wiki)
      • Fisher-Yates Shuffle-yates | (wiki)
      • Erastothenes Sieve | (wiki)
      • Extented GCD algorithm | (wiki)
      • Karatsuba's Multiplication | (wiki)
      • Newton's Squarenewton-sqrt | (wiki)
      • Permutations Count
      • Strassen's matrixstrassen | (wiki)
    • Sorting algorithms
    • Searching algorithms
      • Binary Search | wiki
  • Crypto

    • Hashing wiki | MIT
      • md5, wiki | code
      • sha1, wiki |code
      • sha256, wiki |code
      • sha512, wiki |code
      • hmac, wiki |code
      • bcrypt, wiki |code
    • Encryption or Ciphers MIT
      • aes, code
      • cipher, code
      • des, code
      • rc4, code
      • rsa, code
    • Encoding
      • base64, code
  • databases

  • Awesome Go

    • bazel_cpp
    • bazel go
    • config
    • beego
    • go-redis
    • freecache
    • localcache |best practices
    • gorm
    • iris
    • kafkaSarama
    • mapstructure
    • grpc
    • grpc mock
    • zipkin
    • websocket |echo | chat
    • consul | register |grpc-resolver
  • Docs

  • Interview

    • When is defer called?

      It was called according the consuming sequence of stack. That is to say, the first defer clause will be invoked as the last.

    • defer and panic which is run first?

      First defer, then panic.

    • Difference between new() and make()?

      For new function, it returns pointer. It is used when initiate struct. Make is mostly used when initiate slice, map and channel.

    • Can append() receive pointer as parameter?

      No.

    • go run order,
    • Can global variable declared with short declaration?

      No.

    • Difference between passing value and passing pointer as parameter of function?

      When passing value, it will create a new copy. For pointer, it will pass the value itself.

    • str := "hello", str[1] = 'a' Is the string gonna modified?

      No. Because the string is a constant.

    • Can we assign nil to string?

      No. But we can assign nil to *string

    • If map and range is executed by sequence?

      No.

    • If two slice object can be compared with ==?

      No.

    • Is there a difference between new() and “regular” allocation?

      No. &Vector{} , new(Vector) is the same, one thing to note: new() is the only way to get a pointer to an unnamed integer or other basic type. You can write "p := new(int)" but you can't write "p := &int{0}".