V3: [Go] Concept Exercises

Created on 20 Jan 2020  ยท  14Comments  ยท  Source: exercism/v3

Go Concept Exercises

Exercise Flow

2020-03-01_Go_Path

Note: To request a change in the flow, comment on this issue.

Exercise Status

Icon Legend

  • โœ… exercise implemented
  • ๐Ÿ›  is being implemented
  • ๐Ÿ“™ exercise specification issue created
  • ๐Ÿ”ด not started
  • โ“ to be filled

basics

focus: some basics as a starting point. packages, variables, basic functions, basic comments
thoughts: The introductions to the mentioned topics are only rudimentary.
concepts used: packages, variables, functions, comments
status: ๐Ÿ› 
issue: #1438

comments

focus: comments in Go
thoughts: comments on exported identifiers, shape of package comments and function comments, golint, godoc (?)
concepts used: โ“
status: ๐Ÿ“™
issue: #843

code-formatting

focus: code formatting in Go
thoughts: usage of gofmt, auto-format on save in different IDEs, command line usage
concepts used: โ“
status: ๐Ÿ”ด

types

note: will probably be eliminated
focus: very basic introduction to Go's types, declaring variables and defining custom types.
concepts used: โ“
status: ๐Ÿ“™
issue: #836

numbers

focus: int and float64
concepts used: numbers, type conversion, assignment
status: โœ…
issue: #371

numbers-floating-point

focus: more in-depth intro to floats. float64 was briefly introduced in numbers exercise.
concepts used: โ“
status: ๐Ÿ“™
issue: #243

constants

focus: introduction to constants
thoughts: applies to strings, numbers, errors, ..., not maps, slices, ..., usage of iota (exercise should only depend on numbers: int, float64)
concepts used: โ“
status: ๐Ÿ”ด

functions

focus: introduction to functions in Go
concepts used: โ“
status: ๐Ÿ“™
issue: #370

anonymous-functions

focus: introduction to anonymous functions
thoughts: โ“
concepts used: โ“
status: ๐Ÿ“™
issue: #844

conditionals

focus: introduction to if and switch
concepts used: โ“
status: ๐Ÿ› 
issue: #428

iteration

focus: introduction to the for loop (no range loop)
concepts used: conditionals, numbers, functions
status: ๐Ÿ› 
issue: #619

basic-slices

focus: working with slices. instantiate (len, cap), append, set single value, read value, remove value, taking length
concepts used: iteration, functions, conditionals, numbers
status: โœ…
issue: #530

maps

focus: introduction to maps
concepts used: functions, strings, integers, conditionals
status: ๐Ÿ› 
issue: #427

range-iteration

focus: introduction to the for range loop (no channel reading)
concepts used: โ“
status: ๐Ÿ“™
issue: #426

bytes-and-runes

focus: special intro to bytes and runes and slices of bytes and runes
concepts used: โ“
status: ๐Ÿ“™
issue: #424

basic-strings

focus: string manipulation and formatting
concepts used: string manipulation, string formatting, slices, type conversion, conditionals, functions
status: โœ…
issue: #237

nil

focus: introduction to nil, default values
thoughts: only pointers can be nil, types that are actually pointers: map, slice, channel, etc (can also be nil), default values for other types (string, numbers, bool, etc)
concepts used: โ“
status: ๐Ÿ“™
issue: #835

pointers

focus: introduction to pointers
thoughts: reference to memory address, pass by reference/pass by value, garbage collector
concepts used: โ“
status: ๐Ÿ“™
issue: #845

errors

focus: introduction to errors
thoughts: create errors (errors.New, fmt.Errorf), typed errors and when to use them (public constant errors)
concepts used: โ“
status: ๐Ÿ“™
issue: #846

advanced-errors

focus: introduction to custom errors
thoughts: custom error types and when to use them (custom types implementing error interface), any type can be used as an error when implementing the Error() string function
concepts used: โ“
status: ๐Ÿ“™
issue: #847

error-handling

focus: introduction to error handling
thoughts: if err != nil, return or handle -- not both (logging is handling!), don't ignore errors, every function that can fail should return an error, error always last return value
concepts used: โ“
status: ๐Ÿ“™
issue: #849

panic-and-recover

focus: introduction to panics
thoughts: how to panic, don't panic/when to panic, recover/when to recover, a panic is a bug and should be fixed
concepts used: โ“
status: ๐Ÿ“™
issue: #850

advanced-strings

focus: iterating strings, immutability of strings, advanced formatting
concepts used: โ“
status: ๐Ÿ“™
issue: #340

time-and-duration

focus: working with Time and Duration
thoughts: calculation (diff, since), comparison (before, after), duration constants (second, hour, nanosecond, ...), timezones, formatting, parsing
concepts used: โ“
use parts of: C# datetimes
status: ๐Ÿ”ด

application-timing

focus: time related application concepts
thoughts: sleep, time.After, ticker, timer
concepts used: โ“
status: ๐Ÿ”ด

structs

focus: introduction to structs
thoughts: structs, fields, (not methods), instantiation, default values: NewFunc (?), field usage, exported and private (?)
concepts used: โ“
status: ๐Ÿ”ด

methods

focus: introduction to methods
thoughts: can be attached to any type defined in the same package. method pointer vs value receiver, exported and private (?), methods on structs: Go's "classes" (?)
concepts used: โ“
copy: C# classes
status: ๐Ÿ”ด

goroutines

focus: introduction to goroutines
thoughts: start a goroutine, start goroutines in a loop (references), async: no telling what happens first
concepts used: โ“
status: ๐Ÿ”ด

channels

focus: introduction to channels
thoughts: unbuffered channels, reading and writing (no iterating channels, no select)
concepts used: โ“
status: ๐Ÿ”ด

channel-select

focus: introduction to the select statement
thoughts: โ“
concepts used: โ“
status: ๐Ÿ”ด

waitgroups

focus: usage of WaitGroup
thoughts: โ“
concepts used: โ“
status: ๐Ÿ”ด

context

focus: introduction to different types of contexts
thoughts: background/todo, timeout, cancel, values in contexts (when/why not to use?)
concepts used: โ“
status: ๐Ÿ”ด

anonymous-functions

focus: introduction to anonymous functions
thoughts: โ“
concepts used: โ“
status: ๐Ÿ”ด

defer

focus: introduction to defer
thoughts: โ“
concepts used: โ“
status: ๐Ÿ”ด

mutex

focus: introduction to mutexes
thoughts: Mutex/RWMutex, defer
concepts used: โ“
status: ๐Ÿ”ด

empty-interface

focus: introduction to the empty interface
thoughts: can hold any value but hard/slow to work with, should be used rarely
concepts used: โ“
status: ๐Ÿ”ด

interfaces

focus: introduction to interfaces
thoughts: implicit implementation of interfaces, single Method interface, some common interfaces: Reader, Writer, error
concepts used: โ“
status: ๐Ÿ”ด

reflection

focus: introduction to reflection
thoughts: intro to reflect package, some basic reflection, ...โ“(not type switch, type casting, etc.)
concepts used: โ“
status: ๐Ÿ”ด

type-switch

focus: introduction to type switch
thoughts: probably based on conditionals (which introduces switch), numbers and empty-interface
concepts used: โ“
status: ๐Ÿ”ด

type-casting

focus: introduction to type casting
thoughts: โ“
concepts used: โ“
status: ๐Ÿ”ด

statuhelp-wanted statuin-progress tracgo typdiscussion

All 14 comments

A quick start of possible concept exercises. To be expanded as we go. Mainly as a starting point for tomorrows meeting.

Would concurrency be a good candidate to add as a concept or would it be better to split it into channel, goroutine, select and so on?

I'd also add manipulation with JSON

Would concurrency be a good candidate to add as a concept or would it be better to split it into channel, goroutine, select and so on?

Since this is about concept exercises... we will need to split it up. I think there should be a lot of concept exercises on concurrency.

I'd also add manipulation with JSON

Did I get this right?

Or do you mean: JSON Handling?

sorry,
it was about parsing JSON files, empty interfaces might be

Would concurrency be a good candidate to add as a concept or would it be better to split it into channel, goroutine, select and so on?

I added some of them here as they were missing: https://github.com/exercism/v3/issues/167

From my work on https://github.com/exercism/v3/pull/239 I got to think quite a bit more.

strings in Go are actually dependent on knowing about slices. After all strings are based on []byte. If I want to take a substring, I use ranged indexing into a string (s[4:6]). In C# for example there is a subString method that does this for you, so no need to know about the underlying structure of a string.

Using strings.Split returns a []string. Again needs knowledge of slices as a prerequisite.

Ranging over a string gives be runes with a start-byte index of that rune. Which in turn needs some knowledge about runes and maybe []rune as well as the underlying []byte.


I think we should restart this issue and start over. Remove all the concept exercises we gathered here and start writing down the issues for creating a concept exercise instead. I'd pick a concept I want to take on and create an exercise issue based on that (or multiple if it starts to become too large). Then I'd think really hard on what this exercise should teach, what it shouldn't. Maybe already implement some code I'd want to see as a solution, to see what concepts it depends on (like indexing into slices in my strings sample above). Write down those prerequisites as well.

If the concept exercise is pretty much well defined (just the issue, but with clear definitions concept(s) it will teach and its prerequisites), then make a summary of that in this issue as a comment. Then I'll add it to the description above.


This is a suggestion for now. So I'd like to know what you think!

I think we should restart this issue and start over. Remove all the concept exercises we gathered here and start writing down the issues for creating a concept exercise instead. I'd pick a concept I want to take on and create an exercise issue based on that (or multiple if it starts to become too large). Then I'd think really hard on what this exercise should teach, what it shouldn't. Maybe already implement some code I'd want to see as a solution, to see what concepts it depends on (like indexing into slices in my strings sample above). Write down those prerequisites as well.

If the concept exercise is pretty much well defined (just the issue, but with clear definitions concept(s) it will teach and its prerequisites), then make a summary of that in this issue as a comment. Then I'll add it to the description above.

So I think this is a perfectly reasonable thing to do! I'd not throw away this exercise completely, as it can still be very useful later, but starting with the basic concepts and building on them is also how I approached the C# track and that worked well for me personally.

A lot of new exercises have been added in the description. All with the status ๐Ÿ”ด need issues with specs.

If you want to work on one, add a comment to this issue (#212) naming the one you want to work on (also check if somebody else already works on it), and then create the specification issue for the new concept exercise using the [MAINTAINERS] Implement new Concept Exercise template.

I'm going to work on errors, custom-errors, error-handling and panic-and-recover next. (Creating issues for them: ๐Ÿ”ด --> ๐Ÿ“™)

@tehsphinx Would it perhaps make sense to link to issues from this list? E.g. any ๐Ÿ“™ issue will have an accompanying issue, right? If so, it might make sense to link to it directly from this list.

Added issue links in the description.

Great!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ErikSchierboom picture ErikSchierboom  ยท  3Comments

ErikSchierboom picture ErikSchierboom  ยท  6Comments

valentin-p picture valentin-p  ยท  5Comments

ErikSchierboom picture ErikSchierboom  ยท  6Comments

tehsphinx picture tehsphinx  ยท  5Comments