text
stringlengths
0
2.35k
**Jaana Dogan:** Such a tough life, yeah.
**Mat Ryer:** And you told me earlier that everything you do at work is completely confidential. Do you wanna just break all the rules and tell us anyway, or...?
**Jaana Dogan:** Well, kind of... I'm actually about to switch to a new job. I mean, not a new job, but sort of like a new role. Currently, I'm still exploring what I'm supposed to do, and... It's confidential, not because it's supposed to be super-confidential, but I am not sure about what I will be focusing on, so......
**Mat Ryer:** Yeah, absolutely. Obviously, I do take it very personally, but I'll pretend that I don't. Well, also joining us on today's show, it's only Johnny Boursiquot. Hello, Johnny!
**Johnny Boursiquot:** Hello there.
**Mat Ryer:** And speaking of new gigs, you've just started yours, haven't you?
**Johnny Boursiquot:** Yeah, recently. It's been a couple weeks. I'm still on-boarding, as they say. But yeah, it's still exciting, I'm still looking forward to contributing and learning... New gigs are always exciting that way; there's that honeymoon period where everything is new, and you're learning; you're learning...
**Mat Ryer:** \[06:01\] Oh, good. I'm glad to hear it. Yes, it is exciting. It's scary and exciting all at the same time, new jobs. But yeah, I wish you all the best. If you don't mind, we'll keep asking you about it on the show, because I'm very interested; I think it's useful for other people as well to hear about th...
**Johnny Boursiquot:** Sure thing.
**Mat Ryer:** Let's jump straight in. We're gonna be talking about Go tools today. I asked on Twitter earlier which of the Go tools are people's favorites, or which ones do they like the most... I'll just kick off - mine probably has to be `go fmt` (go format). For those that don't know, it formats all the Go code so i...
If you think about pull requests, with white space... Sometimes pull requests having loads of white space makes it really difficult to see what the crux of the change is. Well, with `go fmt` we don't have that problem, because it's all formatted nicely.
Anyone else? How do you feel about `go fmt`? How do you pronounce it, by the way? Let's just get that one out of the way.
**Jaana Dogan:** `go fmt`, right?
**Mat Ryer:** Okay, good.
**Jaana Dogan:** I mean, that's what I know. \[laughs\]
**Mat Ryer:** Yeah, that's what I'm told.
**Johnny Boursiquot:** It's always awkward when I'm teaching something and I say "the fmt package", for example... People kind of look at me sideways; I'm like "Yeah, I know. I know. Just go with it." If you say "fmt" or "format", God forbid, gophers are gonna look at you a little weird, like "We did just go with it."
**Jaana Dogan:** Yeah, it takes a while for people to parse it initially, and then they learn it and they take it and they don't question it... I'm trying to keep it consistent by saying "`go fmt`".
**Mat Ryer:** Yeah, same. I agree. I've done that, I don't think naturally, but I heard about it, and yeah, I do it for consistency, too.
It's funny, because sometimes people will say "golang", because when we use Google and we search, or when we use hashtags, we tend to write "golang", but we never say "golang." So it's a little pro tip for anyone that's new to the Go community - when you're talking about the language, just call it Go. Don't say "golang...
**Johnny Boursiquot:** With regards to `go fmt`, the reason -- well, let me step back for a little bit. When I first came across `go fmt`, I was taken aback, honestly, because I wasn't used to basically tooling, formatting my code to look in a standardized way. I come from programming languages where everybody has thei...
\[10:04\] People would have these back-and-forths around styling, what's more readable versus what's not as readable... And obviously, it was all sort of subjective. Everybody has their own preferences, their own quirks and what they're used to and what they're not used to... But `go fmt` sort of threw all of that out ...
I'll be honest, for the first month or so, I was like "I don't like everything about what it does. I'm happy with 90% of it, but I don't like everything about it." But then as time went on, I really began to love the tool and what it does. The beauty of it - I think you touched on that - is that every Go code started l...
**Jaana Dogan:** Yeah. There's actually something from Robert Griesemer that he used to say... He's the person who's maintaining `go fmt`, and all the rules and so on. He says that he doesn't agree with all the styling; he doesn't necessarily agree with `go fmt`, but some tool is enforcing it, so there's no question.
I work for a very large company and I witnessed -- it took like four years to just tweak one little style guideline change on the Java style guideline. And can you imagine - there's all these hundreds of people with strong opinions about style just wasting four years debating on minor style issues... I like the fact th...
**Mat Ryer:** Yeah. Do you think they would be able to retrospectively fit that into the toolchain? Say that there wasn't `go fmt` originally, and it just came out now... Do you think the community and everyone would rally around it in the same way, or do you think there's something to be said for the fact that this wa...
**Jaana Dogan:** I think it's necessary that initially you create some initial culture around -- you know, just relying on a tool... Because I think it creates this community with enough people supporting an idea, and understanding why it's valuable. If you try to inject this type of tool at a later time, the community...
**Mat Ryer:** Yeah, I agree with you. There's a few examples where the foresight or the insight from the team in the original design -- I think we really benefit from some of those decisions, and we'll talk about more of them as well. I think the fact that another one of the tools, go test - that was there as well, fro...
**Jaana Dogan:** \[14:04\] Yeah, I think Go is doing a good job in terms of identifying 80% of what is essential in software engineering, and I think tooling is also representing those priorities.
**Mat Ryer:** Thinking beyond `go fmt` then, if we look at Golint and also Govet, does anyone wanna have a stab at describing the difference between those two, or describing what they actually do? \[pause\] Cool. Well... \[laughter\] Yeah, so Golint - I like it. It essentially looks at your code and does some static an...
One example is if you have something in a package that's exported, if it starts with a capital letter, then you should have a comment on that, really. That's the accepted practice. Now, the Go spec doesn't say that, so it's not a compile error if you don't have a comment there... But the Golint tool will catch it and s...
And there are a few rules around how we write comments as well, where we repeat the name as the first word in the comment. So there's a few little things like that that are encoded in the linter, right?
**Jaana Dogan:** Yeah. Well, we need to mention first, I think there's a difference between that and lint. That is reporting more of like suspicious stuff, and some patterns that might be a misuse of an API that may corrupt some memory, or whatever. Think about the typical example of printf - if you pass the wrong type...
So lint is more about style errors. For example Godoc, a public API, is going to complain about that type of problems. So that became a part of the test, but not all the things that is reported as a part of that is genuine. There could be false positives, as far as I know. And it also applies to lint as well. These are...
**Mat Ryer:** Yeah, you're right. If you use printf or wrapf, if you use one of those f methods and then you don't put the correct number of verbs/arguments in, catching things like that is extremely useful, because it's quite hard at a glance to just see those kinds of mistakes. So yeah, I think people should switch o...
The comment one is a good example. It's quite dogmatic. It just says "Okay, it's exported, so it needs a comment." Now if that function says "new thing", then it's obvious that's making a new thing, and your comment is probably gonna say "new thing makes a new thing." So we have a little bit of redundancy, but I think ...
**Johnny Boursiquot:** \[18:22\] One of the things that I typically do, and partly the reason why for me, off the top of my head, differentiating between the linting and the vetting was I was like "Hm, I guess, I've never really talked about the difference that much, because they're part of my toolchain." In my day-to-...
There's another popular open source project out there that I think is called gometalinter, which includes a bunch of those tools, as well. You can configure it, turn some off and others on, and whatnot. But these tools together, they give you a set of outputs that you can basically go through and figure out "Oh yeah, I...
I almost don't care, I should say, which tools give me what, unless I really need to work with a specific tool... But it's part of my workflow, they're just a part of my editor, and everytime I hit Save, formatting gets done, Goimports does its thing, whatever I'm referencing in my code that is not imported - it brings...
**Jaana Dogan:** Yeah, it's a good point actually making it a part of the everything experience; it's really useful. Especially vet is reporting a lot of useful stuff, like "Hey, this is unreachable", or you're passing for example unmarshal a non-pointer, and stuff like that... It's so hard sometimes when you're typing...
**Mat Ryer:** Yeah, and I extend that to running tests as well. I tend to write unit tests, which run very quickly, and then you can run those everytime you save the package, usually. If they start getting too slow, then of course you have to have a different strategy, but certainly in the beginning, if it's unit tests...
And Johnny, by the way, the gometalinter now apparently is called golangci-lint. So if you want to install that into VS Code, it's golangci-lint. That's the new name of that.
**Johnny Boursiquot:** Interesting.
**Mat Ryer:** But you're right, it's the metalinter - it runs a range of other linters, and kind of gives you that one view of it. And they integrate brilliantly into the IDEs as well. So that's the other things, like you say... You can run it on Save, but even if you don't, you can still usually integrate it into the ...
**Johnny Boursiquot:** \[22:25\] And you shouldn't have to wait until -- if you have continuous integration (CI), you should; but you shouldn't have to wait until that code reaches that remote server, where all these tools are run, for you to get that feedback. It's much easier and much faster. Like you're saying, that...
Then when it goes up for review, for a PR, whatever CI tool you're using - Travis, Circle, whatever; there's dozens of them these days - they give it a blessing, and now people can just focus on what does the code do. They don't have to tell you "Hey, you forgot to run `go fmt` on it", or something. You take advantage ...
**Jaana Dogan:** Yeah, one of the best parts is they are really fast also. It's part of the editing experience, because they're fast. I'm coming from a background where I used a lot of Java tools, and it's not like it's a smooth experience. We used to have similar static tools, but it was not as smooth as all these Go ...
**Break:** \[23:55\]
**Mat Ryer:** We mentioned go test. That's another tool that we use a lot. Anyone that's not used it - if you write test codes in your Go programs, you do that usually by naming the file with \_test.go at the end, and then you run go test. It will look through all those test files and it will actually run all the test ...
There's also another little feature in the test tool which I think gets overlooked a little bit... It's the race detector. When you're writing concurrent code, it's possible for you to break the rules and try and read and write from the same data at the same time; if you try and do something like that, that's illegal a...