ch5ex12

command
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

README

= Exercise 5.12
// Refs:
:url-base: https://github.com/fenegroni/TGPL-exercise-solutions
:workflow: workflows/Exercise 5.12
:action: actions/workflows/ch5ex12.yml
:url-workflow: {url-base}/{workflow}
:url-action: {url-base}/{action}
:badge-exercise: image:{url-workflow}/badge.svg?branch=main[link={url-action}]

{badge-exercise}

The `startElement` and `endElement` functions in
`gopl.io/ch5/outline2` (_Section 5.5_)
share a global variable, `depth`.
Turn them into anonymous functions that share a variable
local to the `outline` function.

== Test

We first write the test for outline to validate
the original implementation from the book works.

Then we make the code testable.

We factor out the URL processing part of `outline` into `outlineURL`,
and test again.

Finally, we move `startElement`, `endElement` and `depth` into `outline`.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL