Learn Go with tests
Contribute on github
Primary version
Primary version
  • Learn Go with Tests
  • Go fundamentals
    • Install Go
    • Hello, World
    • Integers
    • Iteration
    • Arrays and slices
    • Structs, methods & interfaces
    • Pointers & errors
    • Maps
    • Dependency Injection
    • Mocking
    • Concurrency
    • Select
    • Reflection
    • Sync
    • Context
    • Intro to property based tests
    • Maths
  • Build an application
    • Intro
    • HTTP server
    • JSON, routing and embedding
    • IO and sorting
    • Command line & package structure
    • Time
    • WebSockets
  • Questions and answers
    • OS Exec
    • Error types
    • Context-aware Reader
    • Revisiting HTTP Handlers
  • Meta
    • Why unit tests and how to make them work for you
    • Contributing
    • Chapter Template
Powered by GitBook
On this page
  • Here is the code we have so far
  • Write the test first
  • Try to run the test
  • Write enough code to make it pass
  • Refactor
  • One final refactor
  • Embedding
  • Any downsides?
  • Write the test first
  • Why not test the JSON string?
  • Data modelling
  • JSON decoding
  • Try to run the test
  • Write enough code to make it pass
  • Encoding and Decoding
  • Refactor
  • Write the test first
  • Try to run the test
  • Write the minimal amount of code for the test to run and check the failing test output
  • Write enough code to make it pass
  • Refactor
  • Write the test first
  • Try to run the test
  • Write enough code to make it pass
  • Refactor
  • Write the test first
  • Try to run the test
  • Write enough code to make it pass
  • Wrapping up
  1. Build an application

JSON, routing and embedding

PreviousHTTP serverNextIO and sorting

Last updated 5 years ago