Git Product home page Git Product logo

go-exercises's Introduction

Learning Go

Exercises based on https://www.udemy.com/share/1013gwCUcSdVxRRnQ=/

How to run the examples

Best way to check the code is to run in debug mode, stepping into functions and examining variables and program execution flow.

  • each section is encapsulated in a separate go file
  • each file has one meted exposed that in turn calls all other methods
  • method names describe type of exercise, sometimes comments are used for clarity
  • use VS Code debugger to step through code
    • set breakpoint on the module you want to check out: F9
    • run with debugger: F5
  • from here you can:
    • step into a function: F11
    • step over line of code (let it execute): F10
    • step out from function (useful for stepping out of go code and long loops): Shift + F11

Topics

Learning topics with random notes and observations.

  • Variables, values, types

    • Go has type inference and compiler was able to infer type of all variables so far

    • := operator creates a variable and assigns value to it in one statement

    • ",ok" or comma ok idiom:

      if seconds, ok := timeZone[tz]; ok {
          return seconds
      }
  • Control flow

  • Grouping data

  • Structs

  • Functions

    • functions that have receiver (operate on a type), are called methods and usually mutate state
    • functions that are not methods try to be "pure functions"
    • there is no enforcement of pure functions concept in Go

    • interfaces allow to define behavior and polymorphism like in C#
    • not sure if it's idiomatic, but it's possible to use functional composition in Go, like in F#. Looks like this is under callback pattern.
  • Pointers

    • & operator shows variable address
    • * returns a value stored at an address
    • * with a type like *int is a type of pointer
    • * with a value like *valueName is a de-referencing operator to show what value is under a memory address
    • use pointers with large data sets, instead of passing it by value (similar as passing by reference in C#?)
  • Application

  • Concurrency

  • Channels

  • Error handling

  • Writing documentation

  • Testing & benchmarking

Links & Resources

go-exercises's People

Contributors

piotr1215 avatar renovate[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

go-exercises's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

dockerfile
.devcontainer/Dockerfile
  • mcr.microsoft.com/vscode/devcontainers/go 0-1.16
gomod
go.mod
  • go 1.19

  • Check this box to trigger a request for Renovate to run again on this repository

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.