text stringlengths 0 2.35k |
|---|
[2164.14 --> 2169.18] And then within that body, you can set variables or you can template some. |
[2169.48 --> 2172.52] Like if you just type something without using the brackets, right? |
[2172.54 --> 2174.52] That's going to be output as part of the template. |
[2174.98 --> 2175.06] Yeah. |
[2175.16 --> 2178.96] If you have two blocks of code within a range and in between you say continue, |
[2179.14 --> 2180.62] then the second block is going to be omitted. |
[2180.80 --> 2183.02] And then you're going to go back to the top of the range, right? |
[2183.36 --> 2183.52] Yeah. |
[2183.56 --> 2183.78] Okay. |
[2183.82 --> 2185.56] So that is how it works and goes. |
[2185.66 --> 2186.78] So that should feel quite natural. |
[2186.78 --> 2188.78] But that is quite unusual for templating. |
[2189.10 --> 2190.48] I don't think I've seen that before. |
[2190.58 --> 2191.38] It is a bit unusual. |
[2191.52 --> 2191.76] Yes. |
[2192.16 --> 2192.54] Very cool. |
[2192.54 --> 2197.58] Well, we have somebody here, of course, Michael Matloub, |
[2197.82 --> 2202.62] who has done a fair bit of work recently on workspaces. |
[2202.98 --> 2205.58] And this is coming in Go 118. |
[2205.96 --> 2208.98] Michael, could you just tell us briefly what are Go workspaces? |
[2209.08 --> 2210.22] What problem do they solve? |
[2211.00 --> 2216.28] So just like at a simple level, the Go command in the module mode |
[2216.28 --> 2220.34] allows you to have a single main module that you're working on, right? |
[2220.34 --> 2224.82] Like that's the module that your current directory is in. |
[2225.38 --> 2232.34] And all the files in the module, all the packages in the module are like the modules that are the packages that Go builds by default. |
[2232.34 --> 2241.02] And if you have any other code on disk, previously you would have to like add replaces or other ways of kind of getting it in, |
[2241.30 --> 2245.38] which are kind of annoying if you want to make changes across modules. |
[2245.48 --> 2248.34] It was hard to work across two modules at the same time, basically. |
[2249.04 --> 2252.40] Now, workspaces allow you to have more than one main module. |
[2252.40 --> 2260.04] Those are modules where you are making edits and Go builds from rather than getting it from a specific version. |
[2260.76 --> 2264.42] And so Workspace is allowed you to say, these are the modules on this that I'm working on. |
[2264.72 --> 2274.06] And those are like the base that the minimal version selection uses when computing its dependency graph. |
[2274.06 --> 2282.36] So we think this is going to be useful because we've gotten a lot of feedback from people who work across multiple modules. |
[2282.52 --> 2288.06] In fact, that was like one of the number one complaints we saw in the Go user survey. |
[2288.62 --> 2295.76] People working with modules that they had problems when they were working on multiple modules, they found it cumbersome. |
[2296.44 --> 2300.66] And so we hope that multi-module workspaces make that workflow a lot easier for them. |
[2301.06 --> 2303.08] Yeah, this is definitely something I've encountered. |
[2303.08 --> 2306.84] Do you think people were like overusing modules? |
[2307.44 --> 2311.18] Do you think that there's like, you know, we were doing something wrong? |
[2311.26 --> 2314.42] It felt like that because we were kind of fighting with the tools a little bit. |
[2314.80 --> 2317.18] What do you mean overusing modules? |
[2317.54 --> 2322.10] Well, I mean, like sometimes in a project, you have like multiple packages. |
[2322.78 --> 2328.40] Sometimes people will, each one of those would be a module instead of just a package inside this bigger module. |
[2328.58 --> 2329.36] Things like that. |
[2329.36 --> 2349.22] Yeah, I feel like one thing that we learned after, you know, some experimentation with modules, like after some time using like Vgo and then modules in the Go command, we learned that multi-module repositories are, they should be rare. |
[2349.22 --> 2353.22] They have a lot of surprises when you're working with them. |
[2353.22 --> 2371.84] And so like now our general recommendation is for people to usually have like one module per repository unless there's a specific, very rare set of use cases where they wanted to have a sub module in their module. |
[2371.84 --> 2378.92] So in that sense, yeah, I guess people, we were overusing modules because we were learning how to use modules. |
[2379.26 --> 2384.08] And now those modules exist and we kind of have to work with them. |
[2384.36 --> 2384.50] Yeah. |
[2384.70 --> 2391.52] I think for like packages and things for if you're releasing a library that people are going to use, I think that's kind of great advice. |
[2391.66 --> 2395.22] Definitely a time I've seen where multiple modules exist is if you have a mono repo. |
[2395.22 --> 2403.62] And the way that you would do it at the moment, I use Visual Studio Code, you basically open the folder, the subfolder just as the root. |
[2403.90 --> 2406.94] And that's essentially like that becomes the context of that module. |
[2407.16 --> 2408.80] And that's a way to get around it. |
[2408.86 --> 2415.42] If you have multiple folders and they have modules in different ones, the workspaces, I think, is going to enable that now. |
[2415.52 --> 2417.70] So you'll be able to operate, right? |
[2417.70 --> 2418.34] Yeah. |
[2418.58 --> 2435.72] I mean, one of the driving forces behind us starting to work on modules was the user experience in not just Visual Studio Code, but like any editors that use Go, please, which kind of powers the Visual Studio Code Go experience. |
[2435.72 --> 2443.82] The team was thinking of different ways of representing multiple modules and providing that information to the Go command. |
[2444.44 --> 2450.56] But it had to like kind of introduce a new concept that like didn't exist in the Go command. |
[2450.64 --> 2455.14] Like the Go command had no concept of like people working in multiple modules at the same time. |
[2455.20 --> 2458.64] It just had, you know, replace directives or requirements. |
[2458.64 --> 2465.24] And so we decided like the best thing to do is to like make this a first class feature of the Go command. |
[2465.54 --> 2476.42] So not only could Go please use it, but users who introduce modules can then open up, you know, command line and the Go command understand that they're working in the same workspace and the same set of modules. |
[2477.28 --> 2479.34] So how does it actually work in practice then? |
[2479.42 --> 2482.16] Do you have to like set up a workspace? |
[2482.38 --> 2484.72] Is this a new concept of a thing you create? |
[2485.06 --> 2485.62] Yes. |
[2485.62 --> 2490.10] So we have Go.mod files and now we have Go.work files. |
[2490.48 --> 2492.00] So you create a Go.work file. |
[2492.12 --> 2494.40] The syntax is very similar to Go.mod. |
[2494.58 --> 2496.48] We want it to be easy for people to pick up. |
[2497.10 --> 2502.02] And the Go.work has one new directive is the use directive. |
[2502.44 --> 2506.06] So you tell it which directories you want it to use. |
[2506.40 --> 2513.82] And all the modules in those directories, if you're under the Go.work file, the same way you're under a Go.mod file before, are in your workspace. |
[2513.82 --> 2518.46] So you make your Go.work file and CD under it. |
[2518.62 --> 2524.62] And now you're using all those modules and any builds that you do or Go list or any such command like that. |
[2525.08 --> 2529.62] And it's going to be aware of those other modules and you're not going to be fighting the tools anymore. |
[2530.00 --> 2530.18] Yep. |
[2530.18 --> 2532.68] And can you do replaces as well in there? |
[2532.90 --> 2533.50] You can. |
[2534.14 --> 2540.68] We don't think people should need to add replaces except in like very specific circumstances. |
[2540.82 --> 2547.54] We actually added replace because if you have multiple modules in your workspaces, they might have conflicting replaces. |
[2547.54 --> 2553.48] And so the replacing the Go.work file can override the replaces that are fighting. |
[2554.42 --> 2562.22] But if you wanted to use a specific module, then usually the right thing to do is just use that module in your Go.work file. |
[2562.70 --> 2562.84] Yeah. |
[2563.10 --> 2568.70] So I feel like lots of tools probably got touched by adding this kind of support. |
[2569.02 --> 2570.88] Was it a difficult one to get in? |
[2571.22 --> 2574.90] Most of the work was in the Go command itself. |
[2574.90 --> 2584.14] I mean, there is definitely like an amount of complexity in the Go command because our module loading code does more than you'd think. |
[2584.80 --> 2590.80] But once we got it to work in the Go command, one of the nice things is most of our tools call into the Go command. |
[2591.56 --> 2602.10] And so, you know, as long as they're making a call into the, you know, Go packages or the Go command, they kind of get all that for free as long as the Go.work file exists on disk. |
[2602.10 --> 2612.88] You know, we've had to like make on the VS Code Go and Go please teams, they've made changes to understand Go.work files and pass them into the Go command. |
[2613.20 --> 2618.24] But, you know, once you pass it in, like all the hard work is done by the Go command itself. |
[2618.72 --> 2620.62] This is a really nice thing to have. |
[2620.92 --> 2624.00] In the way that I work, this is going to change a lot. |
[2624.26 --> 2627.44] There's an experiment for a while where you could try this out. |
[2627.44 --> 2628.18] Wasn't there? |
[2628.40 --> 2629.52] With an environment variable. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.