ch5ex5

package
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: 6 Imported by: 0

README

= Exercise 5.5
// Refs:
:url-base: https://github.com/fenegroni/TGPL-exercise-solutions
:workflow: workflows/Exercise 5.5
:action: actions/workflows/ch5ex5.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}

Implement `countWordsAndImages`.
(See Exercise 4.9 for word splitting.)

== Test

This is an example of a function that multiple return values.
Such functions are called _multi values functions_.

For the test's `got` variable I defined a struct `result`.

There's an exported function `CountWordsAndImages`,
which calls upon `countWordsAndImages`:
a recursive function
similar to `Visit` in Exercise 5.1.

We do not test the exported function
nor provide an example of how to call the inner function.
We will test the exported function in the future using `gomock`.

== Example

We don't provide examples for internal functions.

Documentation

Overview

CountWordsAndImages counts the words and images in each HTML document. The URL to each document is supplied on the command line.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountWordsAndImages

func CountWordsAndImages(url string) (words, images int, err error)

CountWordsAndImages does an HTTP GET request for the HTML document url and returns the number of words and images in it

Types

This section is empty.

Jump to

Keyboard shortcuts

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