Exercise: Create a Trait

Let's go through what you’ve learned in this chapter.

We'll cover the following

This exercise is all about creating your own trait.

Problem statement

You need to represent actions in an exercise routine with structures, each of which implements a go function. Create a new trait named Action that requires a go function. Create a structure named Jump and make its go function print the word Jump.

Coding challenge

Add tests for the application below. We encourage you to try solving it yourself before looking at the solution.

Get hands-on with 1400+ tech skills courses.