learn-go-with-tests icon indicating copy to clipboard operation
learn-go-with-tests copied to clipboard

clockface package is imported but "undefined: clockface" is expected

Open seanburlington opened this issue 2 years ago • 1 comments

clockface package is imported

https://github.com/quii/learn-go-with-tests/blob/00a4dc18ca4aeea4a5ceed999e2257a13e5f91fb/math.md?plain=1#L137

But "undefined clockface" is expected

https://github.com/quii/learn-go-with-tests/blob/00a4dc18ca4aeea4a5ceed999e2257a13e5f91fb/math.md?plain=1#L159-L164

Additionally the import is for a url which returns 404

github.com/gypsydave5/learn-go-with-tests/math/v1/clockface"

If it was wanted I think it should be

github.com/quii/learn-go-with-tests/math/v1/clockface

But I think actually the import isn't needed

There are a few instances of this import statement in the instructions - I'm not clear yet if they are needed

seanburlington avatar Jan 29 '22 21:01 seanburlington

I think this is kind of a duplicate of #457

Essentially I was a bit confused about external tests here

I have started a fork to try and work up what I think might be missing - not ready for a PR yet

https://github.com/seanburlington/learn-go-with-tests/commit/188d01dc2512b7b57fa40fdae6655077daffe56c

seanburlington avatar Jan 31 '22 11:01 seanburlington

As of Feb 12th 2023, the web version of this chapter doesn't include the import, and this causes the testing code to fail as it has no definition for 'clockface' yet...

.\clockface_test.go:11:10: undefined: clockface
.\clockface_test.go:12:9: undefined: clockface
FAIL    maths [build failed]

...but this is not addressed in the chapter text.

Interestingly, the web version also shows an error near this step as:

--- FAIL: TestSecondHandAtMidnight (0.00s)
    clockface_test.go:17: Got {0 0}, wanted {150 60}
FAIL
exit status 1
FAIL	github.com/gypsydave5/learn-go-with-tests/math/v1/clockface	0.006s

...with the reference to the import apparently still intact in that error-generating code.

As a person newly learning Go, and not using the pre-written code from github, I wasn't sure if this was all intentional and I had done something very wrong in my (VSCode? Go?) configuration or even just my file naming, since my failing code was exactly the same as the passing code shown. (Or maybe it somehow addressed the "clockface" package name as an object of sorts? and directly accessed Point through that? Or something in Go was actually deprecated, similar to GOPATH? And other such thoughts.)

Other points made in the aforementioned #457 also hit home -- specifically, using different package names for the primary and test files. Lastly, as a bit of an aside, I'm using a go.work file to follow along with this tutorial, and it may be good to introduce that relatively new Go feature as well?

[edit] Resolved the conflict in my local tests by removing my existing go.mod file, initializing it with go mod init clockface, and importing "clockface" from the clockface_test.go file. (I had previously used go mod init maths for the go.mod file -- something I'd been wondering for some time through multiple Go tutorials exactly how or when the naming needs to be more precise. [/edit]

godprobe avatar Feb 12 '23 21:02 godprobe

I've added some clarifications about the test packages in this PR: https://github.com/quii/learn-go-with-tests/pull/686

And thanks for this feedback, I've also added the package import in this one with an example project name: https://github.com/quii/learn-go-with-tests/pull/687

ruthmoog avatar Jul 12 '23 20:07 ruthmoog

further removed references to @quii and @gypsydave5 's projects using a standard path of learn-go-with-tests/math/clockface where it's used https://github.com/quii/learn-go-with-tests/pull/688

ruthmoog avatar Jul 14 '23 13:07 ruthmoog

ty @ruthmoog

gypsydave5 avatar Jul 25 '23 08:07 gypsydave5