Skip to content

DanWlker/studying_the_GOpher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 

Repository files navigation

Go Notes

Huge Golang Guide

Useful Repos

  1. golangci-lint

  2. golangci-lint-config-examples

  3. gci

     gci write --skip-generated -s standard -s default -s localmodule .
    
  4. gofumpt

  5. mingo

Stack Overflow || Reddit

  1. What does the . in a Go import statement do

    • Allows functions inside the package to be called directly, but is not recommended
  2. When should you use errors.As and when to use errors.Is for your own custom errors

    • errors.Is for var errors, errors.As for struct errors that has to be initialized (especially if it has custom fields)
  3. When to use Golang's default MUX versus doing your own

  4. Should I use ServeMux or http directly in golang

  5. When to use and not to use generics

  6. How to test a unexported (private) function in go (golang)?, the article

  7. How to add new methods to an existing type in Go?

  8. Go constants beyond basics

  9. Why to not choose Ginkgo

Good Articles

  1. init() in Go Programming

  2. Go best practices, six years in

  3. How I write HTTP services in Go after 13 years

  4. Channel Axioms

  5. Proper HTTP Shutdown in Go

  6. Golang Trick: Export unexport method for test

  7. Mastering Go Structs: 7 Advanced Techniques for Efficient Code

  8. Understanding Go's UTF-8 Support

  9. Google style guide assertion libraries

Bites from the Golang Manual (aka. RTFM)

  1. nil_error behaviors

  2. Constants

  3. Go 1.23 timer changes

  4. Go subtests

Good Videos

  1. Go concurrency patterns

  2. 7 Deadly Mistakes Beginner Go Developers Make (and how to fix them)

    • You can label loops apparently
    • map, slice, values in an interface are not addressable
    • Pointer receivers can only accept pointers, while value receivers can accept both values and pointers
  3. Golang struct configuration pattern

    • Use a struct to pass optional values
    • Allow the constructing function to take a list of functions that can modify the options to allow for extensibility
  4. GopherCon 2016: Francesc Campoy - Understanding nil

    • 16:30
    • Use nil to disable channels
    • Nil is valid as a read only empty map
  5. The standard library now has all you need for advanced routing in Go

  6. GothamGo 2018 - Things in Go I Never Use by Mat Ryer

    • Lazy initialization (20:54)
      • sync.Once: Guarantees thing inside code block will be called exactly once
    • You can pass {the struct you want to work on} to {a method called on the struct using dot, ex. Struct.method(actualObject)}, don't do this but its interesting (22:20)
  7. Golang UK Conference 2016 - Dave Cheney - SOLID Go Design

    • Single Responsibility Principle
      • Structure functions and types into packages that exhibit natural cohesion
      • Avoid shared, utils, which causes the packages to have multiple responsibilities
    • Open / Closed Principle
      • Open for extension, closed for modification
      • Use embedding rather than inheritanca
    • Liskov Substitution Principle
      • Implicit interfaces, use small interfaces and express the dependencies between packages as interfaces
      • Require no more, promise no less
    • Interface Segregation Principle
      • Clients should not be forced to depend on methods they don't use
      • Ex. A Save function should only need a Writer, instead of Read or File, or even Close, therefore it can work with network writer, file writers etc
    • Dependency Inversion Principle
      • High level modules should not depend on low level modules, both should depend on abstractions
      • Abstractions should not depend on details. Details should depend on abstractions
      • Import graph should be acyclic, push responsibility as high as possible in the import tree
  8. Golang UK Conference 2016 - Mat Ryer - Idiomatic Go Tricks

    • 9:16: defer log.Println("------") even if exits abnormally this code will print
    • defer can also be used for teardown functions for any setup / timers that need to stop at end of the line
    • 21:18: Retry code
    • 22:10: Empty structs to group methods methods don't capture the receiver, so the variable need not expose the private type
    • 23:40: Semaphore code, limit hom many stuff is executed at once
  9. How To Build A Chat And Data Feed With WebSockets In Golang?

Good Books

  1. 100 Go Mistakes and How to Avoid Them

Notes

  1. runtime.NumCPU
  2. runtime.GOMAXPROCS()

Others

  1. Introduction to gRPC

  2. What is the difference between grpc and websocket?

  3. Will WebSocket survive HTTP/2

  4. gRPC vs WebSockets

  5. Docker stop containers

  6. Docker distroless Docker exec failed: No such file or directory when CGO is enabled

  7. Golang's null safety proposal discussion

  8. Postgres don't do this

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published