text
stringlengths
0
2.35k
[902.30 --> 903.94] for things that you might change.
[903.94 --> 908.68] So one example is, if you have something in a package that's exported,
[908.94 --> 913.92] if it starts with a capital letter, then you should have a comment on that, really.
[914.04 --> 915.78] That's the sort of accepted practice.
[916.28 --> 918.48] Now, the Go spec doesn't say that.
[918.66 --> 922.74] So, of course, nothing, you know, it's not a compile error if you don't have a comment there.
[923.08 --> 928.10] But GoLint tool will catch it and say, you know, for maximum kind of quality,
[928.30 --> 931.94] for the best quality, you should consider putting a comment here.
[931.94 --> 934.88] And there are a few rules around how we write comments as well,
[934.94 --> 938.82] where we repeat the name as the first word in the comment.
[939.18 --> 943.84] And so there's a few little things like that that are encoded in the Lint, right?
[944.42 --> 944.60] Yeah.
[945.12 --> 948.24] There's, you know, initial actually, like we need to mention first,
[948.30 --> 950.38] I think there's a difference between that and Lint.
[950.74 --> 953.66] That is, you know, reporting more of like suspicious stuff.
[953.66 --> 963.16] And, you know, like some patterns that might be just, you know, might be just,
[963.76 --> 969.38] I mean, a misuse of the, of an API that it may actually, you know,
[969.42 --> 971.80] just kind of like corrupt some memory or whatever.
[972.30 --> 975.30] Like think about like the typical example of printf.
[975.70 --> 978.88] If, you know, you pass the wrong type of arguments,
[979.00 --> 982.20] Beth is going to complain about it.
[982.20 --> 986.70] So both Lint is more about like, I think style errors,
[986.96 --> 989.72] more of like, if you don't, for example,
[990.08 --> 991.80] Godok, a public API,
[992.16 --> 995.24] it's going to complain about that type of problems.
[995.96 --> 997.84] So that became a part of the test,
[997.96 --> 1003.30] but like not, I think all the things that is reported as a part of Beth is genuine.
[1004.24 --> 1008.34] So you can like, there could be like false positives as far as I know.
[1008.34 --> 1011.84] And it also applies to Lint as well.
[1011.84 --> 1015.64] So these are not like a part of the compiler because, you know,
[1016.00 --> 1021.96] there's like some reports that is not accurate or something.
[1022.86 --> 1026.22] But it's just generally like, you know, you need to follow.
[1026.22 --> 1032.08] So they generally generate like genuine enough reports and they're really useful.
[1032.74 --> 1033.18] Yeah, you're right.
[1033.26 --> 1037.40] When it catches, if you use like printf or wrapf,
[1037.44 --> 1039.08] if you use one of those f methods,
[1039.08 --> 1044.50] and then you don't put the correct number of verbs or whatever the arguments in,
[1044.90 --> 1047.26] catching things like that is extremely useful
[1047.26 --> 1051.38] because it's quite hard at a glance to just see those kinds of mistakes.
[1052.16 --> 1057.36] So yeah, I think people should switch on those tools for their code base,
[1057.42 --> 1058.94] at least run them for their code base,
[1059.06 --> 1062.00] and see what kinds of things it is actually saying,
[1062.12 --> 1064.38] because you might find you agree with them.
[1064.78 --> 1066.22] The comment one's a good example.
[1066.52 --> 1069.34] I mean, it's quite dogmatic.
[1069.50 --> 1072.00] It just says, okay, it's exported, so it needs a comment.
[1072.00 --> 1076.38] Now, if that method is something like,
[1076.52 --> 1078.90] or if it's a function that says new thing,
[1079.38 --> 1082.12] then it's obvious that's making a new thing.
[1082.24 --> 1085.48] And your comment's probably going to say, new thing makes a new thing.
[1085.88 --> 1088.56] So we have a little bit of redundancy.
[1088.92 --> 1093.24] But I think generally speaking, if you do follow the Lint tools,
[1093.52 --> 1097.96] then I find that, you know, the code, again, it starts to look more familiar
[1097.96 --> 1101.76] and you get all the other benefits of GoFund.
[1102.00 --> 1105.08] One of the things that I typically do,
[1105.24 --> 1109.80] which is probably the reason why, for me,
[1110.28 --> 1111.68] like off the top of my head,
[1111.74 --> 1115.42] sort of differentiating between the linting and the vetting was sort of,
[1115.76 --> 1118.62] I was like, hmm, I guess I've never really thought about the difference that much
[1118.62 --> 1120.72] because they're part of my tool chain.
[1120.94 --> 1127.90] So like on my day-to-day, I use VS Code and Vim as sort of my editors of choice.
[1127.90 --> 1131.62] And basically they have the plugins, you know,
[1131.76 --> 1134.60] and the extensions sort of built in as part of my workflows.
[1134.76 --> 1138.78] Every time I hit save, right, these tools are running, right?
[1139.12 --> 1142.06] And I'm getting different, basically,
[1142.42 --> 1146.18] markers at different spots from different tools, right?
[1146.18 --> 1149.06] So there's another popular open source project out there,
[1149.26 --> 1150.68] I think it's called the GoMetLinter,
[1151.32 --> 1153.94] which includes a bunch of those kinds of tools as well.
[1154.02 --> 1157.24] You can configure, you can turn some off and others on and whatnot.
[1157.60 --> 1159.14] But these tools together,
[1159.22 --> 1163.00] they give you sort of a set of outputs that you can basically go through
[1163.00 --> 1164.98] and figure out, oh, yeah, I missed, you know,
[1164.98 --> 1165.96] I used the wrong verb here.
[1166.02 --> 1167.60] I'm supposed to use an integer.
[1167.60 --> 1169.12] I'm using a string instead, right?
[1169.32 --> 1174.44] Things that the linter and vet would sort of find for you
[1174.44 --> 1176.16] and if you run them sort of individually.
[1176.70 --> 1178.32] But because they're part of my tool chain,
[1178.82 --> 1182.18] basically I just look at the view at the bottom of my editor
[1182.18 --> 1184.40] and get a list of things that I go and fix.
[1184.54 --> 1188.54] So I've sort of almost basically, I don't care, I should say,
[1188.68 --> 1193.36] which tools give me what unless I really need to work with a specific tool.
[1193.82 --> 1195.42] But I kind of, you know, it's part of my workflow.
[1195.54 --> 1196.44] It's just part of my editor.
[1196.44 --> 1198.90] Every time I hit save, formatting gets done.
[1199.62 --> 1200.72] Go import says this thing.
[1200.88 --> 1203.52] Whatever I've referenced in my code that is not imported,
[1203.74 --> 1205.02] it brings that in automatically.
[1205.66 --> 1206.88] All these things sort of happen.
[1207.20 --> 1211.32] The tooling kind of makes it easy to sort of just focus on writing the code
[1211.32 --> 1215.08] and not worry so much about having to run individual tools one at a time.
[1215.86 --> 1219.30] Yeah, it's a good point that actually making it that part of, you know,
[1219.34 --> 1221.26] the editing experience is really useful.
[1221.82 --> 1225.44] Like a special vet is reporting a lot of like, you know, useful stuff like,
[1225.44 --> 1229.72] okay, this is unreachable or, you know, you're passing the wrong, you know,
[1229.72 --> 1235.36] you're passing, for example, unmartial and non-pointer and like stuff like that.
[1235.42 --> 1241.40] Like it's so hard sometimes by just when you're typing and when you're just like coding,
[1241.40 --> 1245.34] but like tool is really helping you to do the right thing as you are, you know, programming.
[1245.34 --> 1248.60] Yeah, and I extend that to running tests as well.