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

tour: interface module is wildly confusing #1662

Open
Johnsoct opened this issue Oct 28, 2024 · 1 comment
Open

tour: interface module is wildly confusing #1662

Johnsoct opened this issue Oct 28, 2024 · 1 comment

Comments

@Johnsoct
Copy link

What's confusing?

  • MyFloat is called out of nowhere. Where does it come from? Is it built-in? Is it just a "tutorial-thing" you're suppose to ignore?
  • Vertex isn't defined above like in every other module in the tour, and it's not imported either...
  • What kind of name is Abser for the interface? Is there some naming convention that's unique to interfaces in Go?
  • What are "method signatures?" That's the first time they've been mentioned even after going through 5-6 modules on methods.
  • "A value of interface type can hold any value that implements those methods" - isn't an interface just wrapping a defined type with methods? Why are interfaces special? What use them over how methods were explained in the last five modules?
  • In the above statement, it says the values of an interface type hold values that implement methods, and then in the code below, it says the method assigned to the interface implements the interface???
	a = f  // a MyFloat implements Abser
	a = &v // a *Vertex implements Abser
  • The bug you're suppose to "fix" is confusing because you're reassigning the value of the interface to a new value... why does it matter if it's not a pointer? You're told it's wrong, but it's not clear why when you're reassigning the interface... Also, again, I thought interfaces hold values that implement methods, but the comment above the bug says v does not implement Abser.

Coming from JavaScript, I recognize Go is a lot different given it's based on C, and C is very different and less friendly than JavaScript, but I've spent 15-30minutes per module of the "methods and interfaces" category going to the documentation to not just get a better understanding of the module contents but just understand enough to move on... It would be great if some of these could consider people are trying to tour Go without coming from a similar language.

image

@Johnsoct
Copy link
Author

I just watched this video... https://www.youtube.com/watch?v=lbW-KVdIXaY

Incredibly easy to follow...

An interface type groups defined types together by their methods.
An interface type defines the criteria, based on methods, for what can be considered one of that interface.

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

1 participant