Skip to content

Repository files navigation

Go Course

Table of content

  • Dependency management
  • HTTP server
    • http test utils
    • json en/decoding
    • graceful shutdown
  • Makefile
    • Run tests
    • Run static checks
    • Build binary
    • Build Docker image
    • go mod in Makefile
  • Error handling
    • fmt.Errorf()
    • errors.New()
  • Coding patterns/conventions
    • Struct methods
    • Embedded structs
    • Early exit strategy
    • Interfaces
  • Folder structure
    • Single command (main in root)
    • Multi command (cmd/{name}/main.go})
  • Testing
    • Basic test function
    • Assert and require
    • Table driven testing
    • HTTP testing
    • Benchmarking
  • Profiling
    • CPU
    • Memory
    • Tracing
    • HTTP load testing
  • Docker
    • security
    • multistage build
    • image size
    • boot up time

Extra material:

  • Goroutines, channels, WaitGroups, etc
  • Anonymous functions and closures
  • Mocks in testing
  • Debugger
  • Integration tests

Flow

  • Initial commit
    • create repo
    • clone repo
  • Add README and Makefile
    • add test target
    • go mod init
  • Initial TODO list implementation
    • test case for todo list
    • add lint target
    • add vendor target
    • make vendor
    • List struct
    • Task struct
    • Create pointer receivers for List
    • Split Task to Task and TaskData
    • Static error
  • Add benchmark
    • add benchmark target
  • Add TaskData validation and table-driven tests
    • table-driven testing
    • convert to subtests
    • add utf-8 string in test
    • fix string validation to support utf-8
  • Use parallel subtests
    • wrap with t.Run()
    • copy test variable
  • Validate string length in runes
    • fix validate function implementation
  • Take TaskData validation in use and add benchcmp
    • use validate func in Add method
    • add benchcmp target
    • run benchcmp
  • Add test case for rest API
    • create test case with Recorder
    • make vendor
    • create test case with TestServer
  • Implement REST API for todo list
    • create Handler struct
    • wrapper List implementation
    • create endpoint handlers
  • Make api test parallel
    • race detection
  • Make todo list thread safe
    • atomic uint
    • sync map
    • benchcomp
  • Add cmd to run server
    • add build target
    • init todo list and router
    • start server
    • listen SIGINT and SIGTERM
    • graceful shutdown
    • demonstrate with sleep in handler func
  • Create api and mem subpackages
    • move List to mem
    • move Handler to api
    • create interface for List
  • Create postgres implementation of List
    • create postgres implementation of List
    • test by taking into use in main.go
  • Add Dockerfile
    • add docker-image target
    • add docker-run target
    • create multistage dockerfile
  • Add targets for docker image size and boot up time
    • compare with reference java implementation
  • Add http load testing targets
    • add docker-stats target
    • add wrk target
    • add vegeta target
    • java vs go
      • memory usage
      • avg req/s
      • java warmup time
      • perf while warming up
  • Add profiling targets and pprof server
    • add profiling server
    • add cpu-profile target
    • add heap-profile target
    • add test-profile target
    • expose 6060 port for docker
    • show cpu profile
    • show heap profile
    • change CreatedAt to UTC()
    • compare mem usage
  • Add execution tracer target
    • add trace-profile target
    • profile while wrk-post is running
  • Add clean target
    • clean prof, html, bin, build, etc files

Example queries

Create task:

printf '{"Name": "my task", "CreatedAt": "%s"}' $(date -Is) | curl -H 'Content-Type: application/json' -d @- 127.0.0.1:8000/api/tasks

Get task:

curl localhost:8000/api/tasks/0

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages