Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken functions references in math chapter #812

Open
BenBout opened this issue Oct 12, 2024 · 1 comment
Open

Broken functions references in math chapter #812

BenBout opened this issue Oct 12, 2024 · 1 comment

Comments

@BenBout
Copy link

BenBout commented Oct 12, 2024

Hello, at v7c step in chapter math, some functions references are broken.

func simpleTime(hours, minutes, seconds int) time.Time {
	return time.Date(312, time.October, 28, hours, minutes, seconds, 0, time.UTC)
}

func testName(t time.Time) string {
	return t.Format("15:04:05")
}
  • These functions are privates and declared in the file math/v7c/clockface/clockface_test.go which is in package clockface.
  • These functions are called in math/v7c/clockface/clockface_acceptance_test.go which is in package clockface_test. We can't call them as they are privates functions from clockface package.

The problem is : we don't want these functions to be public in clockface package.
As go developper, how do you resolve properly this issue ? Do you create a common package for test utility functions, used by clockface_test and clockface package ?

@maker2413
Copy link

maker2413 commented Oct 20, 2024

I ran into this as well. It was never mentioned in the book, but you can see in the sample code that simpleTime and testName have been recreated in the clockface_acceptance_test.go file: https://github.com/quii/learn-go-with-tests/blob/main/math/v7c/clockface/clockface_acceptance_test.go#L76-L82

Ultimately either this logic has to be changed for the code to work or the book's text will have to be updated to state that these functions should copy pasted in the acceptance test file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants