Giter Club home page Giter Club logo

golang-learn-with-tdd's Introduction

Startup

Learning golang with quick book quii.

Golang standard

  • Package managment.
  • Learned about integers.
  • Interactions.
  • struct, methods and interfaces.

Golang test library

  • how create assertion helpers functions.
  • how write benchmarks.
  • how create tests example code (helpful to documentation).
  • how display many tests itentions with tc.Run()
  • how use table driven tests

Maps

  • Create maps
  • Search items to maps
  • Update items in maps
  • Delete items from a map
  • Learn more about
    • How to create errors that are constants
    • Writing error wrappers

Mocking

Create mocks is really important, because we can test only business logic without take care with third part systems. Our code would be more effective and take a fast feedback.

Without mocking important areas of your code will be untested. In our case we would not be able to test that our code paused between each print but there are countless other examples. Calling a service that can fail? Wanting to test your system in a particular state? It is very hard to test these scenarios without mocking.

Without mocks you may have to set up databases and other third parties things just to test simple business rules. You're likely to have slow tests, resulting in slow feedback loops.

By having to spin up a database or a webservice to test something you're likely to have fragile tests due to the unreliability of such services.

read more: Test Dobule

Concurrency

Concurrency in go is great. We've to be able to create code that execute things in the same time. The syntax is nice and simplier.

channels

Channel allow to communicate with caller function and write things in memory in the same time.

  • Waiting groups configure that the function should be wait of the all goroutines finish
  • Mutex tell to scheduler that the shared item of memory is open or lock to change, so the goroutine need to wait until the item is open to change.

Select

Able that we receive data from multiple goroutines base on switch case statement. It's very helpful when we need to choice which data we want to use.

Note: It's very common to create a case with a signal that abort channels to avoid a block.

Httptest

A package that allow we interfaces a real net/http servers which is consistent.

Generics

  • Mading a generic array and slices.
  • Assertions for generics types.
  • Creating generics with type-safety.
  • Understand about interface{} and any, both are the same, and use it lost type-safety of Go.

golang-learn-with-tdd's People

Contributors

mrayone avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.