4 ms·
I applaud the approach and the effort, but there are some basic things in this book that are just not correct, or are difficult to read. One random page that I
by chrisbroadfoot 10y ago
I applaud the approach and the effort, but there are some basic things in this book that are just not correct, or are difficult to read.
One random page that I jumped to:
https://thewhitetulip.gitbooks.io/webapp-with-golang-anti-textbook/content/content/02.5.html https://thewhitetulip.gitbooks.io/webapp-with-golang-anti-te...
> Go doesn't allow us to have functions as a part of structs
I don't know what this means. Functions can be fields in structs.
> These methods can only be called by an instance of the struct.
That's not true. Methods are just regular functions, with some syntactic sugar to make them look like methods from other programming languages. They are not dispatched on the receiver value, but rather based on the type.
https://play.golang.org/p/ER2r58_BRz https://play.golang.org/p/ER2r58_BRz
- thewhitetulip 10y agoYou are right, the writing is wrong. I was trying to imply in the C++ class sense where we write functions directly inside a class, in Go, we have to define a function over a struct. In your example: you call the method using an instance of T right? that was what I was saying, we have to define methods outside the struct declaration and then call it using an object of struct. (*t).F(nil)
- jamra 10y agoIf t is nil, the function is still called with a nil value for t.
- thewhitetulip 10y agocan we call the method without doing t.F()? like just F()? I accept I have to modify the statement I made.
- chrisbroadfoot 10y agoNo. F refers to a different function than t.F.
- thewhitetulip 10y agoYes that was my point when i said we can't declare functions inside struct We can have methods which work on objects on structs but never a function like class's method
- deleted 10y ago[deleted]
- mirekrusin 10y agoIt's "nice effort" in similar sense that 2 year old girl's painting is "nice painting". Almost every sentence (I've read) has unintentional message between lines saying that the author is very young and an amateurish programmer. Who knows, maybe this is the best way to learn anything! Just write down what you know as gitbook and let people send you corrections - just the things you need to know, brilliant! :)
- sctb 10y agoThis comment violates the Show HN guidelines. Please don't do this here. https://news.ycombinator.com/showhn.html https://news.ycombinator.com/showhn.html
- mirekrusin 10y agoNo it doesn't "When something isn't good, you needn't pretend that it is.". I'm not using offensive language like "you are stupid" or similar. It is however a critique comment pointing out that the work is amateurish. Just look at it - text and code are full of false information and bugs. It's obvious it's written by somebody with very little experience.