I, for one, am happy that the new mic stand actually didn’t get rid of the keypresses. I would say they definitely add to the live coding feel of your videos.
I don't have all the libraries you have or something, but mine came out: most common global variable names 5 kernel32 2 procGetConsoleMode 2 modified 2 cpuprofile 2 doc
+Jan Erik Keller actually, I updated the numbers and wrote a blog post on it “Understanding Go programs with go/parser” @francesc medium.com/@francesc/understanding-go-programs-with-go-parser-c4e88a6edb87
Great video Francesc! Interesting thing, those ASTs. You can even use `format.Node` to print formatted Go code. This basically means you can generate Go code programmatically by "simply" defining the AST values you just parsed.
I think the reason for `v` having been the most used identifier and now not being the most used variable is that `v` is used as parameter in functions (e.g. `v interface{}`) which variable counting program does not consider.
Hi! I'm still an apprentice in Go. There's something unspoken that makes me somewhat uneasy: you've shown with the int visitor that traversal actually _copies_ of the visitor that visit children, so, unless I'm missed something, this works because the visitor features only maps, which are reference types, so all the visitors are actually updating the same maps. Likewise, I'm uneasy with the code in the repo where some methods change these maps yet they take the visitor by value, not by pointer. Is this typical go coding style?
+Akim Demaille this is idiomatic Go, yes you could define a struct with a map inside and define the method on it's pointer but there's really no need to do so
Thanks Francesc, great learning episode as usual. A tip: goast.yuroyoro.net is an AST visualizer website. if one simply wants to inspect the random source snippet.
+Mark Richman We wrote a `go-corp-linter` which does company specific linting of rules we want to enforced for our developers. So quite useful I would say.
I, for one, am happy that the new mic stand actually didn’t get rid of the keypresses. I would say they definitely add to the live coding feel of your videos.
I don't have all the libraries you have or something, but mine came out:
most common global variable names
5 kernel32
2 procGetConsoleMode
2 modified
2 cpuprofile
2 doc
Hi,
v is a typical name of an function parameter. Since we didn't consider the declaration of these, the number is way lower.
+Jan Erik Keller so I modified the code ... and v now appears *only* on the 4th position :)
+Jan Erik Keller actually, I updated the numbers and wrote a blog post on it
“Understanding Go programs with go/parser” @francesc medium.com/@francesc/understanding-go-programs-with-go-parser-c4e88a6edb87
Cool :)
Hey Francesc, thanks for the episode, what about an another one using AST to generate automatically an API documentation for example ?
+Sébastien FRIESS oh that's kinda cool ... tell me more
we did similar thing to generate an openapi spec from comments in go code, it works pretty well but still in a early stage
If you use idiomatique Go HTTP API, on could use AST to generate the routes documentation, HTTP verbs, used structs as DTO, etc ?
Great video Francesc! Interesting thing, those ASTs. You can even use `format.Node` to print formatted Go code. This basically means you can generate Go code programmatically by "simply" defining the AST values you just parsed.
+Etienne Bruines yup, I had a quick section on go/printer that I ended up dropping
You could check for the exported variables
I think the reason for `v` having been the most used identifier and now not being the most used variable is that `v` is used as parameter in functions (e.g. `v interface{}`) which variable counting program does not consider.
+Uwe Dauernheim that's a very good guess, but there's only one way to know ... writing the code 😎
Francesc can you also do some episode on commonly used topics like design patterns in golang, big multi file projects in golang, etc. Thanks
Please do a video on go/types!
Hi! I'm still an apprentice in Go. There's something unspoken that makes me somewhat uneasy: you've shown with the int visitor that traversal actually _copies_ of the visitor that visit children, so, unless I'm missed something, this works because the visitor features only maps, which are reference types, so all the visitors are actually updating the same maps. Likewise, I'm uneasy with the code in the repo where some methods change these maps yet they take the visitor by value, not by pointer. Is this typical go coding style?
+Akim Demaille this is idiomatic Go, yes
you could define a struct with a map inside and define the method on it's pointer but there's really no need to do so
Hey Francesc, how to read a build program instead of text file ?
Thanks Francesc, great learning episode as usual. A tip: goast.yuroyoro.net is an AST visualizer website. if one simply wants to inspect the random source snippet.
thank you so much
might you try a recursive analysis of embedded types ? just for fun =)
Good explanation, thanks a lot!
“Nobody walks in LA” except ast.Walk
This is an interesting academic topic, but I don't think most Go developers would get much use out of it in their daily work.
+Mark Richman parsing is only academic? you might be interested in my new company haha
sourced.tech
+Mark Richman We wrote a `go-corp-linter` which does company specific linting of rules we want to enforced for our developers. So quite useful I would say.
Uwe Dauernheim I didn’t say it wasn’t useful. It’s just not useful to the majority of Go developers.