10 ms·
Get familiar with workspaces
- pstuart 5y agoNow that Go has generics (and the workspace handling mentioned here) I think it's going to get down to complaining about verbose error handling...
- heavyset_go 5y agoI like Java-style checked exceptions and Rust's Result enums, and my ideal error handling would be more verbose compared to Go's error handling.
- KptMarchewa 5y agoRust's Result type is way less verbose than Go's error handling though. Checked exceptions would have been fine if they composed decently with rest of the language...
- heavyset_go 5y agoWith Rust's result type, you either have to unwrap() them or explicitly handle them with match expressions, whereas if you really wanted to in Go, you could just choose to ignore errors.
- KptMarchewa 5y agoRust has extremely useful "?" operator.
- heavyset_go 5y agoYep, I mentioned that up-thread. It's a very convenient feature.
- deleted 5y ago[deleted]
- foolfoolz 5y agothere’s really no reason this has to be 3 lines if err != nil { return err } i’m hoping they find a way to simplify this
- preseinger 5y agoReturning an unannotated error like this is an antipattern. Every error return should include an annotation via fmt.Errorf.
- nkozyra 5y agoWhy? Errors are annotated by definition. I wouldn't feel better about returning my own string versus the error which already includes a message. How much additional context needs to be there and how often is this convention used by simply duplicating the message with basically repetitive text? panic(err) become "Problem with date formatting: invalid date format" or similar I also think "antipattern" gets thrown around too often. This sounds more like a preference or convention.
- srer 5y agoI presume as a method of manually constructing backtrace, as the same error may occur in multiple places it's helpful to understand the context. I too would label it a preference. To get out of the error handling tedium in our platform I largely opt to panic instead whenever viable, which gives a nice trace for free. (I am but human, and the error handling particularly grates once you have gotten used to just typing `?`.)
- nkozyra 5y agoI also panic whenever possible from the caller, in which case I get a pretty clear stack trace. I understand you don't always want that but imo I don't have a lot of cases where I'm ultimately throwing my hands up on a non-exception error. I think V2 errors are taking more of a lead from the pkg/errors error.Wrap approach anyway.
- tmp_anon_22 5y agoI wonder how practical it would to implement much of Rust's error handling syntactic sugar in Golang. I'm sure a lot doesn't transfer over, but Rust seems to have learned a lot from other languages like Golang in this regard.
- obilgic 5y agoit's going to get down to complaining about introducing generics way too late.
- pstuart 5y agoOnly for those who want to make a stink about it.
- aphistic 5y agoThere's much more to differentiate Rust and Go than support for generics and error handling verbosity. In my mind (and experience) they don't even occupy the same problem space.
- monkey26 5y agoI struggle to see what problem space is better for one or the other. I’ve replaced all my web service type stuff with Rust and couldn’t be happier. Also a lot of stuff I used to do in Python is more concise in Rust. No I hung up my Go boots in 2018, so may be a little out of touch.
- srer 5y agoIMHO: Rust integrates a bit better with existing software. Inclusion of Rust in Linux being an example. Go culture tends to value pure Go projects a bit more than Rust's, where Rust wrappers around C libs are more accepted and common. Go is generally easier from a social point of view, there's not much to learn as it's largely a repeat of what people are familiar with. So introducing it in a workplace is easier as the on ramp is minor. Ubiquitous greenthreading in Go seems to make the integration piece a bit harder, but the onramp a bit easier.
- pstuart 5y agoI was being cheeky. I love Go and have been too busy/lazy to dive into Rust but would like to. Yes, different problem spaces but they often get compared head to head because we need to have stuff to argue over.
- riyadparvez 5y agoThis reminds me of Dan Luu post about outages and post-mortems [1]: > For more on this, Ding Yuan et al. have a great paper and talk: Simple Testing Can Prevent Most Critical Failures: An Analysis of Production Failures in Distributed Data-Intensive Systems. The paper is basically what it says on the tin. The authors define a critical failure as something that can take down a whole cluster or cause data corruption, and then look at a couple hundred bugs in Cassandra, HBase, HDFS, MapReduce, and Redis, to find 48 critical failures. They then look at the causes of those failures and find that most bugs were due to bad error handling. 92% of those failures are actually from errors that are handled incorrectly. [1] https://danluu.com/postmortem-lessons/ https://danluu.com/postmortem-lessons/
- throwaway894345 5y agoI believe this, but I don't think it addresses whether implicit or explicit error handling is more likely to result in correctly handled errors. My opinion is that explicit is better than implicit (and I'm using implicit and explicit loosely here--the `?` operator is technically explicit, but I'm considering it to be implicit since it's easy to overlook a single character).
- deleted 5y ago[deleted]
- stouset 5y agoIt's impossible to overlook that single character because your code won't compile otherwise. Unlike Go, you cannot accidentally ignore an error condition in Rust. There is no way to discard the error without explicitly doing so, and even then you still have to decide on a non-error return value to return (because Rust functions that fail provide an error or a value and not both, unlike fallible golang functions). People who believe Golang is explicit and hard to ignore errors but think that Rust is implicit and easy to ignore errors have never used both languages, full stop. I challenge you to provide me with an example of Rust code that ignores an error without explicitly and obviously doing so.
- 5y ago
- taberiand 5y agoI don't know Go, but this sounds analogous to .net solution / project files - is that kind of what this is?
- metaltyphoon 5y agoYes
- asp_hornet 5y agoIt most definitely isn’t
- asp_hornet 5y agoNo. Imagine you have a nuget package your solution relies on. If you want to test a change to that nuget you would need to change the nuget reference to a local project reference or publish locally. Imagine if you could create a file on the solution level that uses the source code in a directory instead of the nuget without affecting the csproj, sln or nuget references
- GreymanTheGrey 5y agoSomething like this would be a game changer for my workplace. This particular issue is a huge bugbear for our team of 50'ish developers in a .NET development environment, working on a large product with a lot of shared code/models/etc that often has to be updated at the same time as application logic. It is astonishing to me that MS haven't addressed this issue with NuGet workflow and its hostility towards developers working on internal code.
- asp_hornet 5y ago100% agree. These pain points eventually broke me and I just left .net for Go
- accoil 5y agoYou can use Directory.Build.targets, and Directory.Build.props to have shared build targets/properties—including package references. When building MSBuild will keep checking parent directories until it finds those files and imports them. See: https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build https://docs.microsoft.com/en-us/visualstudio/msbuild/custom... I don't use them for package references myself, but this blog post has some information on how you'd do that: https://www.mytechramblings.com/posts/centrally-manage-nuget-versions/ https://www.mytechramblings.com/posts/centrally-manage-nuget...
- malkia 5y agoWow. That's not a small thing to internalize. I guess if you use predominantly Go, then that's good and understanabdle, but if you have more languages in the mix (C/C++, Python, C#, Java, Rust), each of them have their own build ways and quirks (at least with Go/Rust/C# there is build single option (AFAIK)), but then do - do I need to clean now? Is this going to really get my latest change? Is the IDE going to see these new symbols, the debugger, etc. I know people like when their language comes with build system, but that creates a cost when that language/runtime has to be used with others...
- nerdponx 5y agoI don't see how workspaces makes that situation worse. Go has always had its own compiler, package layout, etc.
- malkia 5y agoI think the whole thing is super easy to use, if only for Go. I've had to recompile and patch few things, and I'm relatively unfamiliar with it, and with my little knowledge was able to get through (my main languages are C/C++ and C#, and did Java (+ blaze) while at google, but never touched anything else but Java there, though saw the light of how easy is to integrate between these languages, given enough time spent on making these rules work (it's not always easy, I'm still waiting for external dart/flutter rules, it's yet another system with it's own build mechanism))
- qbasic_forever 5y agoIf you have a lot of different languages in the same repo (like a monorepo scenario), you might be better served using something like bazel. It'll abstract away all the language-specific build systems, for better or worse, and make it a bit more uniform to manage. It's not a panacea--basically everything now has a single annoying build system instead of everything having an annoyingly different native build system.
- malkia 5y agoWell I was hinting at it, or the other similar systems (gn, buck, pants, etc.) - you end up needing a language-agnostic (or rather say, language-diverse system) that understand how these compilers / runtimes express output artifacts and actions. It's not always that easy (e.g. "virtual_includes" in bazel and `#pragma once` do not work well, but it's small price to pay (e.g. go back to #ifndef MY_HEADER_H #define it)).
- throwra620 5y ago
- hendry 5y agoI gather this is an easier way to work with dependencies that you might need to tweak or add some logging lines too or something?
- throwaway894345 5y agoYeah, basically it lets you use a local version of a dependency rather than a published version. This way you can make changes to the dependency and test that they are compatible with your downstream project without needing to resort to hacky workarounds.
- carbocation 5y agoI'm trying to understand the right place to use workspaces. For example, one of my repos contains a bunch of command line tools (under /cmd/toolA, /cmd/toolB subfolders) that make use of shared libraries. Right now, that's one module. But I suppose these could also be separate modules that are joined by a shared workspace. They go into this a little bit under the "Work with multiple interdependent modules in the same repository" section. But what they tout as the benefit in that section isn't really a problem in my current workflow. What would be useful is to let my tools depend on different versions of libraries; I think this might be enabled by workspaces? (whereas right now they share a go.mod)
- disposedtrolley 5y agoI'm looking forward to the improved editor experience as gopls is now workspace-aware. There's a couple of repos at work which contain multiple Go modules (each in their own subdirectory, with their own go.mod files). It's a bit of a pain to get LSP working correctly for each individual module if I open the root directory of the repo in my editor.
- preseinger 5y ago> There's a couple of repos at work which contain multiple Go modules (each in their own subdirectory, with their own go.mod files). There's almost no reason to do this. 1 repo = 1 module. Even for monorepos.
- gkfasdfasdf 5y agoCan you elaborate? What if you have multiple commands (main.go) with differing dependencies?
- preseinger 5y agoThey can (and usually should) exist in a single module. Each compiled artifact will link in only the dependencies it requires, not all of the dependencies of the parent module.
- deleted 5y ago[deleted]
- chairmanwow1 5y agoThis is a great improvement over the existing workflow. Didn’t realize I could use this for protobuf libs pulling in from a common schemas repo
- bushbaba 5y agoI find this goes against the go simplicity. I continually find that Maven & Gradle are much easier to use than Go's package management system for versioned dependencies.
- Thaxll 5y agoWhen people release 500+ pages book to explain a build system, you know you're in trouble. https://www.amazon.com/Maven-Definitive-Guide-Sonatype-Company/dp/0596517335/ https://www.amazon.com/Maven-Definitive-Guide-Sonatype-Compa... Go is way way easier to use than Maven and Gradle. I think I use only 4 commands daily to manage dependencies in Go, it's that easy: https://github.com/golang/go/wiki/Modules#daily-workflow https://github.com/golang/go/wiki/Modules#daily-workflow
- ______-_-______ 5y agoThis might be the first time I've heard someone say comprehensive documentation is a bad thing. Go's module docs are 82 printed pages. Is that better or worse? https://go.dev/ref/mod https://go.dev/ref/mod
- Thaxll 5y agoEvery place I worked, Java build pipeline has always been cumbersome, it's one thing that one guy knows and you're afraid to change it because it's complicated.
- jrockway 5y agoThat's 36 pages printed (try printing it), and includes the grammar for the go.mod file, information about the ecosystem of services available (module proxy, sumdb) and their protocol definitions, how to access and publish private modules, etc. It doesn't skimp on thoroughness anywhere.
- layer8 5y agoThe Sonatype Maven book isn’t actually that comprehensive, unfortunately.
- alimov 5y agoIs this similar to .xcproject / .xcworkspace?
- deleted 5y ago[deleted]