25% off

Use code FUNCMAIN at checkout for 25% off all premium courses.

Get started โ†’

Interactive Go ยท Lesson

Quest: Hero vs Monster

The moment of combat is here. This quest brings together Module 5: a struct for the combatant, a method with a pointer receiver to change its state, and repeated calls to whittle the monster down.

Your Quest

Call TakeDamage(12) on the monster twice, then print its remaining HP. Starting at 30, two 12-damage hits leave:

6

Hint

monster.TakeDamage(12) twice (Go automatically takes the monster’s address for the pointer receiver), then fmt.Println(monster.HP).

Additional Scrolls of Wisdom